Author: cazfi Date: Wed Aug 26 19:57:11 2015 New Revision: 29688 URL: http://svn.gna.org/viewcvs/freeciv?rev=29688&view=rev Log: Avoid sdl/2-client crash if update_unit_info_label() is called with NULL unitlist.
See bug #23809 Modified: branches/S2_5/client/gui-sdl/mapview.c Modified: branches/S2_5/client/gui-sdl/mapview.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-sdl/mapview.c?rev=29688&r1=29687&r2=29688&view=diff ============================================================================== --- branches/S2_5/client/gui-sdl/mapview.c (original) +++ branches/S2_5/client/gui-sdl/mapview.c Wed Aug 26 19:57:11 2015 @@ -497,10 +497,15 @@ SDL_Surface *pBuf_Surf, *pTmpSurf; SDL_String16 *pStr; struct canvas *destcanvas; - struct unit *pUnit = unit_list_get(punitlist, 0); + struct unit *pUnit; + + if (punitlist != NULL && unit_list_size(punitlist) > 0) { + pUnit = unit_list_get(punitlist, 0); + } else { + pUnit = NULL; + } if (SDL_Client_Flags & CF_UNITINFO_SHOWN) { - pInfo_Window = get_unit_info_window_widget(); /* blit theme surface */ @@ -968,7 +973,7 @@ the square under the current unit, for specified unit. Note that in practice punit is always the focus unit. - Clears label if punit is NULL. + Clears label if punitlist is NULL or empty. Typically also updates the cursor for the map_canvas (this is related because the info label may includes "select destination" prompt etc). _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits