summaryrefslogtreecommitdiff
path: root/Build/source/libs/poppler/poppler-src/goo/gmem.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/poppler/poppler-src/goo/gmem.cc')
-rw-r--r--Build/source/libs/poppler/poppler-src/goo/gmem.cc8
1 files changed, 2 insertions, 6 deletions
diff --git a/Build/source/libs/poppler/poppler-src/goo/gmem.cc b/Build/source/libs/poppler/poppler-src/goo/gmem.cc
index 574997fadda..f118fd715d4 100644
--- a/Build/source/libs/poppler/poppler-src/goo/gmem.cc
+++ b/Build/source/libs/poppler/poppler-src/goo/gmem.cc
@@ -178,17 +178,15 @@ void *grealloc_checkoverflow(void *p, size_t size) {
}
inline static void *gmallocn(int nObjs, int objSize, bool checkoverflow) {
- int n;
-
if (nObjs == 0) {
return nullptr;
}
- n = nObjs * objSize;
if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) {
fprintf(stderr, "Bogus memory allocation size\n");
if (checkoverflow) return nullptr;
else exit(1);
}
+ const int n = nObjs * objSize;
return gmalloc(n, checkoverflow);
}
@@ -219,15 +217,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 +232,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);
}