This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: Huge numbers for incr passed to _sbrk
- From: Freddie Chopin <freddie_chopin at op dot pl>
- To: newlib at sourceware dot org
- Date: Thu, 16 Aug 2018 09:41:34 +0200
- Subject: Re: Huge numbers for incr passed to _sbrk
- References: <CAChm1gQqnt-NcO4GG=RKZcHD7HrcFuwLjtDeTupT00Kh0pcXng@mail.gmail.com>
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