[U-Boot] Notification in Malloc

Hi,
During some tests with the u-boot-2010.09 source release, I discovered that when invoking malloc with size 0, the code proceeds and corrupts the malloc structures, thus totally breaking the malloc invocations from then on (malloc will always fail after that). The cause of my problem was a burned flash chip, that returned 0 in regions, in the "cfi_mtd_set_erasesize" call. My solution was to modify the first check of malloc, in order not to freeze when there was an error on the requested space. New condition includes the equal as well as the less:
if ((long)bytes <= 0) return 0;
This seems to fix the problems, after the malloc invocation with size 0. If there is another way to deal with this, plz keep me posted.
Thanks, Nik

Dear Kostaras Nikolaos,
In message 4CBEA38B.9080901@intracomdefense.com you wrote:
error on the requested space. New condition includes the equal as well as the less:
if ((long)bytes <= 0) return 0;
This seems to fix the problems, after the malloc invocation with size 0. If there is another way to deal with this, plz keep me posted.
Makes sense.
Can you please provide a proper patch?
See http://www.denx.de/wiki/U-Boot/Patches for instructions.
Best regards,
Wolfgang Denk
participants (2)
-
Kostaras Nikolaos
-
Wolfgang Denk