diff options
author | Tor Andersson <tor@ghostscript.com> | 2011-02-03 09:07:04 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2011-02-03 09:07:04 +0000 |
commit | ef22e324fbcb12d4adb0eaea45ee109f2e06c1bf (patch) | |
tree | e8db55492151f55de83bca345d62880df5616417 /fitz | |
parent | a89f9abbc6bf0e0836f50324ea94d340c61acf95 (diff) | |
download | mupdf-ef22e324fbcb12d4adb0eaea45ee109f2e06c1bf.tar.xz |
Special case calloc and realloc with zero count or size.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/base_memory.c | 6 |
1 files changed, 6 insertions, 0 deletions
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"); |