Huge numbers for incr passed to _sbrk

Freddie Chopin freddie_chopin@op.pl
Thu Aug 16 09:56:00 GMT 2018


Hello!

Your implementation of sbrk() is actually wrong. It should return
`highest_addr` value from _BEFORE_ it was incremented. For an example
see here:

https://github.com/DISTORTEC/distortos/blob/master/source/newlib/sbrk_r.cpp

In your case you should make a copy of original `highest_addr` value,
do some checking (also before actually modifying `highest_addr`) and
only then increment `highest_addr`. The returned value should be the
copy that you made at the very beginning.

Whether it fixes your original problem is another matter.

Regards,
FCh



More information about the Newlib mailing list