summaryrefslogtreecommitdiff
path: root/debian/patches/0052-xmlmemory-handle-realloc-properly.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/0052-xmlmemory-handle-realloc-properly.patch')
-rw-r--r--debian/patches/0052-xmlmemory-handle-realloc-properly.patch39
1 files changed, 39 insertions, 0 deletions
diff --git a/debian/patches/0052-xmlmemory-handle-realloc-properly.patch b/debian/patches/0052-xmlmemory-handle-realloc-properly.patch
new file mode 100644
index 0000000..f16d038
--- /dev/null
+++ b/debian/patches/0052-xmlmemory-handle-realloc-properly.patch
@@ -0,0 +1,39 @@
+From: Yegor Yefremov <yegorslists@googlemail.com>
+Date: Fri, 10 Oct 2014 12:23:09 +0200
+Subject: xmlmemory: handle realloc properly
+
+If realloc fails, free original pointer.
+
+Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
+---
+ xmlmemory.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/xmlmemory.c b/xmlmemory.c
+index 37dcf3b..6110849 100644
+--- a/xmlmemory.c
++++ b/xmlmemory.c
+@@ -313,7 +313,7 @@ xmlMemMalloc(size_t size)
+ void *
+ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
+ {
+- MEMHDR *p;
++ MEMHDR *p, *tmp;
+ unsigned long number;
+ #ifdef DEBUG_MEMORY
+ size_t oldsize;
+@@ -344,10 +344,12 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
+ #endif
+ xmlMutexUnlock(xmlMemMutex);
+
+- p = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
+- if (!p) {
++ tmp = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
++ if (!tmp) {
++ free(p);
+ goto error;
+ }
++ p = tmp;
+ if (xmlMemTraceBlockAt == ptr) {
+ xmlGenericError(xmlGenericErrorContext,
+ "%p : Realloced(%lu -> %lu) Ok\n",