Commit 7446445d authored by Yegor Yefremov's avatar Yegor Yefremov Committed by Daniel Veillard

xmlmemory: handle realloc properly

If realloc fails, free original pointer.
Signed-off-by: 's avatarYegor Yefremov <yegorslists@googlemail.com>
parent fa23ac1a
......@@ -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",
......
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