AW: [En-Nut-Discussion] Bug Report

Oliver Schulz Oliver.Schulz at
Fri Jan 16 08:52:53 CET 2004

Hi Mike,

thanks for finding this bug. 
I think the first intention of not reallocating smaller buffer sizes is not to waste time for over and over releasing and reserving heap memory again.

But of course, if just a smaller buffer size is needed, the must be adjusted to the smaller buffer. 
For every buffer type I will add an else part to set the correct value.

It's right now in CVS.


-----Ursprüngliche Nachricht-----
Von: Mike Cornelius [mailto:mikec at]
Gesendet: Freitag, 16. Januar 2004 06:56
An: en-Nut-Discussion at Egnite. De
Betreff: [En-Nut-Discussion] Bug Report

Hi All,

I have found a bug in NutNetBufAlloc() netbuf.c

In a number of places there are lines like :-

if (nb-> < size)

If the condition is true (ie the buffer is too small) the old memory block is returned to the heap and a new one assigned nb-> is updated to reflect the new size and all is OK.

However if the new requested size is smaller than the existing size then nothing happens.
This is a problem because nb-> does not get updated to reflect the new smaller size and sometime later on when the network dirver goes to send this packet it sends too many bytes.

I've changed the code to if (nb-> !< size)...

Which works for me but there may be a better way...

Mike Cornelius                      Internet: mikec at
Call Direct Cellular Solutions      Phone:    +61 2 9209-4259
Suite 145                           FAX:      +61 2 9209-4196
National Innovation Centre     URL:
Australian Technology Park
Eveleigh NSW 1430

More information about the En-Nut-Discussion mailing list