[poppler] poppler/goo: gmem.c,1.6,1.7

Albert Astals Cid aacid at kemper.freedesktop.org
Thu Jan 11 14:28:05 PST 2007


Update of /cvs/poppler/poppler/goo
In directory kemper:/tmp/cvs-serv30611/goo

Modified Files:
	gmem.c 
Log Message:
 goo/gmem.c: Merge change from xpdf-3.01pl2


Index: gmem.c
===================================================================
RCS file: /cvs/poppler/poppler/goo/gmem.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gmem.c	28 Dec 2006 15:51:44 -0000	1.6
+++ gmem.c	11 Jan 2007 22:28:03 -0000	1.7
@@ -141,8 +141,11 @@
 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 *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);
   }



More information about the poppler mailing list