Author: cazfi
Date: Tue Nov  3 00:26:50 2015
New Revision: 30377

URL: http://svn.gna.org/viewcvs/freeciv?rev=30377&view=rev
Log:
Fixed a sdl2-client crash when activating an previously completely empty edit 
widget.

See bug #24003

Modified:
    trunk/client/gui-sdl2/widget_edit.c

Modified: trunk/client/gui-sdl2/widget_edit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/widget_edit.c?rev=30377&r1=30376&r2=30377&view=diff
==============================================================================
--- trunk/client/gui-sdl2/widget_edit.c (original)
+++ trunk/client/gui-sdl2/widget_edit.c Tue Nov  3 00:26:50 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
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to