aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Cristau <jcristau@debian.org>2017-01-07 16:20:31 +0100
committerUlrich Sibiller <uli42@gmx.de>2017-03-26 12:45:31 +0200
commit397c786530fb66ff0864b14796dc7036af8f76d9 (patch)
tree0f780255ec71d7e2bd6d5f48055aef8ec053f2cf
parentf5e7d555ad58368cb550b4516b75a1ac3765fda2 (diff)
downloadnx-libs-397c786530fb66ff0864b14796dc7036af8f76d9.tar.gz
nx-libs-397c786530fb66ff0864b14796dc7036af8f76d9.tar.bz2
nx-libs-397c786530fb66ff0864b14796dc7036af8f76d9.zip
Fix wrong Xfree in XListFonts failure pathpatches_up_to_libX11_1.6.5
'ch' gets moved inside the allocated buffer as we're looping through fonts, so keep a reference to the start of the buffer so we can pass that to Xfree in the failure case. Fixes: commit 20a3f99eba5001925b8b313da3accb7900eb1927 "Plug a memory leak" Signed-off-by: Julien Cristau <jcristau@debian.org> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--nx-X11/lib/X11/FontNames.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/nx-X11/lib/X11/FontNames.c b/nx-X11/lib/X11/FontNames.c
index 3e23b5f49..9ffdfd299 100644
--- a/nx-X11/lib/X11/FontNames.c
+++ b/nx-X11/lib/X11/FontNames.c
@@ -43,6 +43,7 @@ int *actualCount) /* RETURN */
register int length;
char **flist = NULL;
char *ch = NULL;
+ char *chstart;
char *chend;
int count = 0;
xListFontsReply rep;
@@ -86,6 +87,7 @@ int *actualCount) /* RETURN */
/*
* unpack into null terminated strings.
*/
+ chstart = ch;
chend = ch + (rlen + 1);
length = *(unsigned char *)ch;
*ch = 1; /* make sure it is non-zero for XFreeFontNames */
@@ -98,14 +100,14 @@ int *actualCount) /* RETURN */
*ch = '\0'; /* and replace with null-termination */
count++;
} else {
- Xfree(ch);
+ Xfree(chstart);
Xfree(flist);
flist = NULL;
count = 0;
break;
}
} else {
- Xfree(ch);
+ Xfree(chstart);
Xfree(flist);
flist = NULL;
count = 0;