From b42f370628f56fdf0d7b9261567eb2033c9ae18a Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 6 Aug 2007 20:45:19 +0200 Subject: [PATCH] para_malloc(), para_realloc(): Check for zero size allocations. --- para.h | 1 + string.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/para.h b/para.h index 7b0ca09c..a4753d4b 100644 --- a/para.h +++ b/para.h @@ -24,6 +24,7 @@ #include #include /* needed by create_pf_socket */ #include +#include #include "gcc-compat.h" /** used in various contexts */ diff --git a/string.c b/string.c index 598a12f5..8b9f1633 100644 --- a/string.c +++ b/string.c @@ -36,6 +36,7 @@ __must_check __malloc void *para_realloc(void *p, size_t size) * No need to check for NULL pointers: If p is NULL, the call * to realloc is equivalent to malloc(size) */ + assert(size); if (!(p = realloc(p, size))) { PARA_EMERG_LOG("realloc failed (size = %zu), aborting\n", size); @@ -58,6 +59,7 @@ __must_check __malloc void *para_realloc(void *p, size_t size) */ __must_check __malloc void *para_malloc(size_t size) { + assert(size); void *p = malloc(size); if (!p) { -- 2.39.5