aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYegor Yefremov <yegorslists@googlemail.com>2014-10-10 12:23:09 +0200
committerDaniel Veillard <veillard@redhat.com>2014-10-13 20:46:37 +0800
commit7446445dec0e46a5af821e57fa5ee04405666efd (patch)
tree7353731d9071f6b2972cfbe94c722111811031e3
parentfa23ac1a796877621a21b8470f2c491d995a5151 (diff)
downloadandroid_external_libxml2-7446445dec0e46a5af821e57fa5ee04405666efd.tar.gz
android_external_libxml2-7446445dec0e46a5af821e57fa5ee04405666efd.tar.bz2
android_external_libxml2-7446445dec0e46a5af821e57fa5ee04405666efd.zip
xmlmemory: handle realloc properly
If realloc fails, free original pointer. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
-rw-r--r--xmlmemory.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/xmlmemory.c b/xmlmemory.c
index 05084e3d..a3dc737f 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",