From 5472fbf921117d20a7d6ba312f7233d5e594cafc Mon Sep 17 00:00:00 2001 From: deuce <> Date: Mon, 19 Dec 2005 22:13:57 +0000 Subject: [PATCH] Be sure to free() the temporary string buffer of the realloc() of the format fails. --- src/xpdev/xpprintf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/xpdev/xpprintf.c b/src/xpdev/xpprintf.c index 9459affd2f..7ed05eb06a 100644 --- a/src/xpdev/xpprintf.c +++ b/src/xpdev/xpprintf.c @@ -1090,8 +1090,11 @@ char *xp_asprintf_next(char *format, int type, ...) * the string. */ newbuf=(char *)realloc(format, format_len-this_format_len+j+1); - if(newbuf==NULL) + if(newbuf==NULL) { + if(entry != entry_buf) + free(entry); return(NULL); + } format=newbuf; /* Move trailing end to make space */ memmove(format+offset+j, format+offset+this_format_len, offset+format_len-this_format_len+1); -- GitLab