From ff06361c71624f08662cec4c87136ac7ba72ae51 Mon Sep 17 00:00:00 2001 From: Menno Valkema Date: Tue, 13 Sep 2016 15:52:51 +0200 Subject: [PATCH] libc: memset valid allocations only in calloc() Fixes #2097 --- repos/libports/src/lib/libc/malloc.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repos/libports/src/lib/libc/malloc.cc b/repos/libports/src/lib/libc/malloc.cc index 923ba1a876..f6901275b2 100644 --- a/repos/libports/src/lib/libc/malloc.cc +++ b/repos/libports/src/lib/libc/malloc.cc @@ -192,7 +192,8 @@ extern "C" void *malloc(size_t size) extern "C" void *calloc(size_t nmemb, size_t size) { void *addr = malloc(nmemb*size); - Genode::memset(addr, 0, nmemb*size); + if (addr) + Genode::memset(addr, 0, nmemb*size); return addr; }