mirror of
https://gitlab.freedesktop.org/xorg/lib/libx11.git
synced 2026-01-06 12:00:13 +01:00
Fix wrong Xfree in XListFonts failure path
'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 20a3f99eba "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>
This commit is contained in:
parent
663f47075f
commit
c74b070f27
1 changed files with 4 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue