diff options
author | Albert Astals Cid <aacid@kde.org> | 2007-01-11 22:29:28 +0000 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2007-01-11 22:29:28 +0000 |
commit | 247eae3939ff52964459bbd1acd0a3be72c7a7a1 (patch) | |
tree | ef0e4eea1cb18c5910f466e456e99d1b5db0af28 | |
parent | be615cf03db00d2d1b8414c1d8c9e2e0a53fa491 (diff) |
goo/gmem.c: Merge change from xpdf-3.01pl2
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | goo/gmem.c | 13 |
2 files changed, 15 insertions, 2 deletions
@@ -1,5 +1,9 @@ 2007-01-11 Albert Astals Cid <aacid@kde.org> + * goo/gmem.c: Merge change from xpdf-3.01pl2 + +2007-01-11 Albert Astals Cid <aacid@kde.org> + * poppler/Catalog.h: * poppler/Catalog.cc: Limit max depth of recursive calls on readPageTree to fix MOAB-06-01-2007 @@ -141,8 +141,11 @@ void *grealloc(void *p, size_t size) { void *gmallocn(int nObjs, int objSize) { int n; + if (nObjs == 0) { + return NULL; + } n = nObjs * objSize; - if (objSize == 0 || n / objSize != nObjs) { + if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) { fprintf(stderr, "Bogus memory allocation size\n"); exit(1); } @@ -152,8 +155,14 @@ void *gmallocn(int nObjs, int objSize) { void *greallocn(void *p, int nObjs, int objSize) { int n; + if (nObjs == 0) { + if (p) { + gfree(p); + } + return NULL; + } n = nObjs * objSize; - if (objSize == 0 || n / objSize != nObjs) { + if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) { fprintf(stderr, "Bogus memory allocation size\n"); exit(1); } |