[poppler] Branch 'xpdf303merge' - 3 commits - goo/gfile.cc goo/gmem.cc goo/GooHash.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Tue Aug 30 11:42:42 PDT 2011
goo/GooHash.cc | 8 ++++++--
goo/gfile.cc | 2 ++
goo/gmem.cc | 28 ++++++++++++++++++++++++----
3 files changed, 32 insertions(+), 6 deletions(-)
New commits:
commit bd1076da03f76fb62998a9409d366412f4aa5d13
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue Aug 30 20:45:36 2011 +0200
xpdf303: Complain for gmalloc and grealloc < 0
diff --git a/goo/gmem.cc b/goo/gmem.cc
index 4189ac1..768b283 100644
--- a/goo/gmem.cc
+++ b/goo/gmem.cc
@@ -71,7 +71,12 @@ inline static void *gmalloc(size_t size, bool checkoverflow) {
void *data;
unsigned long *trl, *p;
- if (size <= 0) {
+ if (size < 0) {
+ fprintf(stderr, "Invalid memory allocation size\n");
+ if (checkoverflow) return NULL;
+ else exit(1);
+ }
+ if (size == 0) {
return NULL;
}
size1 = gMemDataSize(size);
@@ -104,7 +109,12 @@ inline static void *gmalloc(size_t size, bool checkoverflow) {
#else
void *p;
- if (size <= 0) {
+ if (size < 0) {
+ fprintf(stderr, "Invalid memory allocation size\n");
+ if (checkoverflow) return NULL;
+ else exit(1);
+ }
+ if (size == 0) {
return NULL;
}
if (!(p = malloc(size))) {
@@ -130,7 +140,12 @@ inline static void *grealloc(void *p, size_t size, bool checkoverflow) {
void *q;
int oldSize;
- if (size <= 0) {
+ if (size < 0) {
+ fprintf(stderr, "Invalid memory allocation size\n");
+ if (checkoverflow) return NULL;
+ else exit(1);
+ }
+ if (size == 0) {
if (p) {
gfree(p);
}
@@ -149,7 +164,12 @@ inline static void *grealloc(void *p, size_t size, bool checkoverflow) {
#else
void *q;
- if (size <= 0) {
+ if (size < 0) {
+ fprintf(stderr, "Invalid memory allocation size\n");
+ if (checkoverflow) return NULL;
+ else exit(1);
+ }
+ if (size == 0) {
if (p) {
free(p);
}
commit 5a42b3693a9e501a27d790d4aeafcb68f63cb950
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue Aug 30 20:38:39 2011 +0200
xpdf303: Honor the deleteKeys setting
diff --git a/goo/GooHash.cc b/goo/GooHash.cc
index 0b96920..f4a92f1 100644
--- a/goo/GooHash.cc
+++ b/goo/GooHash.cc
@@ -107,7 +107,9 @@ void GooHash::replace(GooString *key, void *val) {
if ((p = find(key, &h))) {
p->val.p = val;
- delete key;
+ if (deleteKeys) {
+ delete key;
+ }
} else {
add(key, val);
}
@@ -119,7 +121,9 @@ void GooHash::replace(GooString *key, int val) {
if ((p = find(key, &h))) {
p->val.i = val;
- delete key;
+ if (deleteKeys) {
+ delete key;
+ }
} else {
add(key, val);
}
commit d584b54eff52c47f983947b2aff0967dfed0ccf9
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue Aug 30 20:36:03 2011 +0200
xpdf303: set to NULL on failure
diff --git a/goo/gfile.cc b/goo/gfile.cc
index 0a23f50..2e4271f 100644
--- a/goo/gfile.cc
+++ b/goo/gfile.cc
@@ -511,6 +511,7 @@ GBool openTempFile(GooString **name, FILE **f, const char *mode) {
*name = new GooString(s);
if (!(*f = fopen((*name)->getCString(), mode))) {
delete (*name);
+ *name = NULL;
return gFalse;
}
return gTrue;
@@ -536,6 +537,7 @@ GBool openTempFile(GooString **name, FILE **f, const char *mode) {
#endif // HAVE_MKSTEMP
if (fd < 0 || !(*f = fdopen(fd, mode))) {
delete *name;
+ *name = NULL;
return gFalse;
}
return gTrue;
More information about the poppler
mailing list