From ef22e324fbcb12d4adb0eaea45ee109f2e06c1bf Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 3 Feb 2011 09:07:04 +0000 Subject: Special case calloc and realloc with zero count or size. --- fitz/base_memory.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'fitz') diff --git a/fitz/base_memory.c b/fitz/base_memory.c index 4153f31e..b7ebb2c9 100644 --- a/fitz/base_memory.c +++ b/fitz/base_memory.c @@ -19,6 +19,9 @@ fz_calloc(int count, int size) { void *p; + if (count == 0 || size == 0) + return 0; + if (count > INT_MAX / size) { fprintf(stderr, "fatal error: out of memory (integer overflow)\n"); @@ -39,6 +42,9 @@ fz_realloc(void *p, int count, int size) { void *np; + if (count == 0 || size == 0) + return p; + if (count > INT_MAX / size) { fprintf(stderr, "fatal error: out of memory (integer overflow)\n"); -- cgit v1.2.3