Commit 4e2a9c49 authored by Albert Astals Cid's avatar Albert Astals Cid

goo/gmem.c: Merge change from xpdf-3.01pl2

parent bce14b27
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:
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment