mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
cxx: add nullptr check in calloc
Even though malloc via the cxx_heap never fails, the implementation of calloc should better not rely on this assumption.
This commit is contained in:
parent
9321067b68
commit
ffc099eb54
@ -87,7 +87,11 @@ extern "C" void *malloc(size_t size)
|
||||
|
||||
extern "C" void *calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *addr = malloc(nmemb*size);
|
||||
void * const addr = malloc(nmemb*size);
|
||||
|
||||
if (addr == nullptr)
|
||||
return nullptr;
|
||||
|
||||
Genode::memset(addr, 0, nmemb*size);
|
||||
return addr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user