[poppler] goo/gmem.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Wed May 23 17:50:13 UTC 2018


 goo/gmem.cc |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit 60ec88b3ca5f109b3532dbf2f36df66aed2d7bbf
Author: Albert Astals Cid <aacid at kde.org>
Date:   Wed May 23 19:49:29 2018 +0200

    greallocn: move the operation to after the checks
    
    fixes oss-fuzz/8484

diff --git a/goo/gmem.cc b/goo/gmem.cc
index 574997fa..46cfc653 100644
--- a/goo/gmem.cc
+++ b/goo/gmem.cc
@@ -219,15 +219,12 @@ void *gmallocn3_checkoverflow(int a, int b, int c) {
 }
 
 inline static void *greallocn(void *p, int nObjs, int objSize, bool checkoverflow) {
-  int n;
-
   if (nObjs == 0) {
     if (p) {
       gfree(p);
     }
     return nullptr;
   }
-  n = nObjs * objSize;
   if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) {
     fprintf(stderr, "Bogus memory allocation size\n");
     if (checkoverflow) {
@@ -237,6 +234,7 @@ inline static void *greallocn(void *p, int nObjs, int objSize, bool checkoverflo
       exit(1);
     }
   }
+  const int n = nObjs * objSize;
   return grealloc(p, n, checkoverflow);
 }
 


More information about the poppler mailing list