Drop assert in zrealloc and raise runtime error
authorStefano Babic <sbabic@denx.de>
Tue, 31 Aug 2021 12:43:12 +0000 (14:43 +0200)
committerStefano Babic <sbabic@denx.de>
Tue, 31 Aug 2021 12:59:23 +0000 (14:59 +0200)
commit07b3d37d53f607e59e74d22fdec85fbeda1360bc
treea4548f67bab13fc6f0323080f56a72fe2792accd
parente3fdd8210610ebe21a44a226888b519672e18986
Drop assert in zrealloc and raise runtime error

Most assert in code are useful because they signal a real bug. However,
if allocation on the heap fails, it is a runtime error because system
gets rid of memory. This is more important on embedded systems,
and the caller process cannot exit but it should be informed with return
code and it will decide how to work on.

This drop the assert clause and add error code handling when zrealloc is
called. Because realloc does not touch the original pointer if fails, it
frees memory to avoid leaks.

Signed-off-by: Stefano Babic <sbabic@denx.de>
src/lib/comp/comp.c
src/lib/comp/zstd/zstd.c
src/lib/dl/multipart.c
src/lib/dl/range.c
src/lib/header.c
src/lib/index/index_create.c
src/lib/zck.c