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

> [EMAIL PROTECTED] - Thu Oct 09 16:02:18 2008]:
> 
> On Thu, 9 Oct 2008 Egor Vyscrebentsov wrote:
> > On Thu, 9 Oct 2008 Egor Vyscrebentsov wrote:
> >
> > > Quickest (not the best) fix is 
> > > 
> > > -          } else if (base_buf) {
> > > +          } else if (base_buf && base_buf[j] != '?') {
> > > 
> > > at server/savegame.c:1862
> > 
> > After some thoughts I've decided that this fix is proper.
> 
> And after some more thoughts I've decided opposite...
> Patch with more or less accurate workaround is attached.

The missing '\0' at the end of base_buf seems to be the main
bug; it is good that you found it.

There seems to be another mistake though, and that is concerning
the two uses of sizeof on a dynamically allocated array:

  sizeof(base_order) / sizeof(struct base_type *)

Since base_order has type struct base_type ** the dividend
will always evaluate to the size of a pointer, which is the
same as the value of the divisor. So the whole expression will
always evaluate to one (which I think is not the desired
behaviour).

I'm guessing that game.control.num_base_types should be used
instead, but even so this sounds suspicious since base_order
is allocated with size nmod + (4 - (nmod % 4)) where nmod is
loaded from the savegame (maybe nmod should be replaced by
game.control.num_base_types in the calloc call?).


> There should be some action after each of two added LOG_ERRORs.
> One variant is to abort civserver. Opinions?

If there's no easy way to handle the error after the error
message (e.g. just dropping the orders for the unit) then abort
is fine. At least that brings the savegame corruption to
attention. :|


----------------------------------------------------------------------
文明の滅亡の間ずっと眠っていたらしい。

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

Reply via email to