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

In S2_2/trunk:

savegame.c:2543: error: array subscript is above array bounds
savegame.c:2543: error: array subscript is above array bounds

     if (tile_worked(pcenter) != pcity) {
       struct city *pwork = tile_worked(pcenter);

       if (NULL != pwork) {
         freelog(LOG_ERROR, "player%d.c%d.workers"
                 " city center is worked by (%d,%d) \"%s\"[%d],"
                 " repairing (%d,%d) \"%s\"[%d]",
                 plrno, i,
                 TILE_XY(city_tile(pwork)), city_name(pwork), pwork->size,
                 TILE_XY(pcenter), city_name(pcity), pcity->size);

         pwork->city_map[x][y] = C_TILE_UNAVAILABLE;

The error is in the last line here and is an incorrect usage of x and y. 
  Those values are set in an earlier iteration but are unset (or 
actually, are out-of-bounds) in this bit of code.  To fix this the 
correct values need to be computed (tile_to_city_pos or something).  The 
line is supposed to make pcity's tile as unavailable for city pwork.

-jason



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

Reply via email to