Author: cazfi
Date: Wed Jan 21 21:11:10 2015
New Revision: 27760

URL: http://svn.gna.org/viewcvs/freeciv?rev=27760&view=rev
Log:
sdl-clients' create_string16() returns NULL instead of illegal pointer when 
font loading fails.

See bug #23195

Modified:
    branches/S2_6/client/gui-sdl/gui_string.c
    branches/S2_6/client/gui-sdl2/gui_string.c

Modified: branches/S2_6/client/gui-sdl/gui_string.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl/gui_string.c?rev=27760&r1=27759&r2=27760&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl/gui_string.c   (original)
+++ branches/S2_6/client/gui-sdl/gui_string.c   Wed Jan 21 21:11:10 2015
@@ -158,8 +158,8 @@
   Font will be loaded or aliased with existing font of that size.
   pInTextString must be allocated in memory (MALLOC/fc_calloc)
 **************************************************************************/
-SDL_String16 * create_string16(Uint16 *pInTextString,
-                                       size_t n_alloc, Uint16 ptsize)
+SDL_String16 *create_string16(Uint16 *pInTextString,
+                              size_t n_alloc, Uint16 ptsize)
 {
   SDL_String16 *str = fc_calloc(1, sizeof(SDL_String16));
 
@@ -172,7 +172,8 @@
   if ((str->font = load_font(str->ptsize)) == NULL) {
     log_error("create_string16: load_font failed");
     FC_FREE(str);
-    return str;
+
+    return NULL;
   }
 
   str->style = TTF_STYLE_NORMAL;

Modified: branches/S2_6/client/gui-sdl2/gui_string.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/gui_string.c?rev=27760&r1=27759&r2=27760&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/gui_string.c  (original)
+++ branches/S2_6/client/gui-sdl2/gui_string.c  Wed Jan 21 21:11:10 2015
@@ -241,7 +241,8 @@
   if ((str->font = load_font(str->ptsize)) == NULL) {
     log_error("create_string16: load_font failed");
     FC_FREE(str);
-    return str;
+
+    return NULL;
   }
 
   str->style = TTF_STYLE_NORMAL;


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to