Author: cazfi
Date: Tue Nov 3 00:26:56 2015
New Revision: 30378
URL: http://svn.gna.org/viewcvs/freeciv?rev=30378&view=rev
Log:
Fixed a sdl2-client crash when activating an previously completely empty edit
widget.
See bug #24003
Modified:
branches/S2_6/client/gui-sdl2/widget_edit.c
Modified: branches/S2_6/client/gui-sdl2/widget_edit.c
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/widget_edit.c?rev=30378&r1=30377&r2=30378&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/widget_edit.c (original)
+++ branches/S2_6/client/gui-sdl2/widget_edit.c Tue Nov 3 00:26:56 2015
@@ -264,23 +264,27 @@
static struct Utf8Char *text2chain(const char *text_in)
{
int i, len;
- struct Utf8Char *pOutChain = NULL;
+ struct Utf8Char *out_chain = NULL;
struct Utf8Char *chr_tmp = NULL;
int j;
+ if (text_in == NULL) {
+ return NULL;
+ }
+
len = strlen(text_in);
if (len == 0) {
- return pOutChain;
- }
-
- pOutChain = fc_calloc(1, sizeof(struct Utf8Char));
- pOutChain->chr[0] = text_in[0];
+ return NULL;
+ }
+
+ out_chain = fc_calloc(1, sizeof(struct Utf8Char));
+ out_chain->chr[0] = text_in[0];
for (j = 1; (text_in[j] & (128 + 64)) == 128; j++) {
- pOutChain->chr[j] = text_in[j];
- }
- pOutChain->bytes = j;
- chr_tmp = pOutChain;
+ out_chain->chr[j] = text_in[j];
+ }
+ out_chain->bytes = j;
+ chr_tmp = out_chain;
for (i = 1; i < len; i += j) {
chr_tmp->next = fc_calloc(1, sizeof(struct Utf8Char));
@@ -293,7 +297,7 @@
chr_tmp = chr_tmp->next;
}
- return pOutChain;
+ return out_chain;
}
/**************************************************************************
_______________________________________________
Freeciv-commits mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-commits