[Freeciv-Dev] Re: servercrash (1.13.1-devel)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Tue, Sep 24, 2002 at 02:20:00PM -0500, Jason Short wrote:
> Thomas Strub wrote:
>
> > civserver: dataio.c:342: dio_put_bit_string: Assertion `bytes < 255'
> > failed.
>
> void dio_put_bit_string(struct data_out *dout, const char *value)
> {
> size_t bits = strlen(value)
bits = 0 in the error case
> , bytes = (bits - 1) / 8 + 1;
bytes = -1/8 + 1 (you may expect that this will be 1 but it isn't if
it is calculated in size_t (an unsigned type). Then it is 2^32/8+1 =
2^24+1 = 16777217. Solution change the type of bytes to int.
> assert(bytes < UCHAR_MAX);
> dio_put_uint8(dout, bits);
> Perhaps I am missing something...but shouldn't the assertion be
> assert(bits < UCHAR_MAX) instead? Otherwise the
> dio_put_uint8(dout,bits) line will fail.
Yes you are right.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
|
|