zephyr/wrapper: Handle OOM correctly in rzalloc()

Fuzzing caught this function failing to handle a heap failure and crashing.

Signed-off-by: Andy Ross <andyross@google.com>
This commit is contained in:
Andy Ross 2022-12-02 14:43:42 -08:00 committed by Liam Girdwood
parent 572a08ea2c
commit 3ae99d937a
1 changed files with 2 additions and 1 deletions

View File

@ -306,7 +306,8 @@ void *rzalloc(enum mem_zone zone, uint32_t flags, uint32_t caps, size_t bytes)
{
void *ptr = rmalloc(zone, flags, caps, bytes);
memset(ptr, 0, bytes);
if (ptr)
memset(ptr, 0, bytes);
return ptr;
}