<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39858 >

> [guest - Mon Nov 12 11:35:46 2007]:
> 
> If I middle click for terrain info on unexplored territory it causes a
crash
> 

(gdb) bt
#0  0x080f4ecd in terrain_name_translation (pterrain=0x0) at terrain.c:131
#1  0x080f6a1c in tile_get_info_text (ptile=0x98da858) at tile.c:460
#2  0x08079376 in popup_info_text (ptile=0x98da858) at text.c:101
#3  0x08120cc0 in popup_terrain_info_dialog (pDest=0x0, ptile=0x98da858)
    at dialogs.c:851
#4  0x081210e2 in terrain_info_callback (pWidget=0x9272c60) at dialogs.c:950
#5  0x0816e020 in widget_pressed_action (pWidget=0x9272c60) at widget.c:402
#6  0x081387e1 in main_mouse_button_down_handler (pButtonEvent=0x8298d9c, 
    pData=0x0) at gui_main.c:331
#7  0x081392b8 in gui_event_loop (pData=0x0, loop_action=0, 
    key_down_handler=0x813851f <main_key_down_handler>, 
    key_up_handler=0x8138785 <main_key_up_handler>, 
    mouse_button_down_handler=0x81387a0 <main_mouse_button_down_handler>, 
    mouse_button_up_handler=0x8138856 <main_mouse_button_up_handler>, 
    mouse_motion_handler=0x81388c7 <main_mouse_motion_handler>)
    at gui_main.c:700
#8  0x0813996e in ui_main (argc=1, argv=0xbfb389d4) at gui_main.c:1000
#9  0x08050945 in main (argc=1, argv=0xbfb389d4) at civclient.c:380

The error is IMO in tile.c which crashes if given a NULL terrain. 
Attached patch should fix it, probably for all branches but definitely 2.1.

-jason

Index: common/terrain.c
===================================================================
--- common/terrain.c	(revision 13944)
+++ common/terrain.c	(working copy)
@@ -128,7 +128,9 @@
 ****************************************************************************/
 const char *terrain_name_translation(struct terrain *pterrain)
 {
-  SANITY_CHECK_TERRAIN(pterrain);
+  if (!pterrain) {
+    return _("Unknown");
+  }
   if (NULL == pterrain->name.translated) {
     /* delayed (unified) translation */
     pterrain->name.translated = ('\0' == pterrain->name.vernacular[0])
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to