[poppler] poppler/goo: gmem.c,1.5,1.5.2.1

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


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

Modified Files:
      Tag: POPPLER_0_5_X
	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.5
retrieving revision 1.5.2.1
diff -u -d -r1.5 -r1.5.2.1
--- gmem.c	28 Feb 2006 19:59:58 -0000	1.5
+++ gmem.c	11 Jan 2007 22:29:28 -0000	1.5.2.1
@@ -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