summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2007-01-11 22:29:28 +0000
committerAlbert Astals Cid <aacid@kde.org>2007-01-11 22:29:28 +0000
commit247eae3939ff52964459bbd1acd0a3be72c7a7a1 (patch)
treeef0e4eea1cb18c5910f466e456e99d1b5db0af28
parentbe615cf03db00d2d1b8414c1d8c9e2e0a53fa491 (diff)
goo/gmem.c: Merge change from xpdf-3.01pl2
-rw-r--r--ChangeLog4
-rw-r--r--goo/gmem.c13
2 files changed, 15 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index a1fd540e..097838b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/goo/gmem.c b/goo/gmem.c
index 6a7de57b..3380b660 100644
--- a/goo/gmem.c
+++ b/goo/gmem.c
@@ -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);
}