Commit 54550ebb authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

XDefaultOMIF.c: Fix memory leaks in get_font_name

Instead of copying the value returned by get_prop_name and then releasing it, directly use the return value of get_prop_name, which allocates memory for the name. If get_prop_name returns NULL, continue on to XFreeFont to release the font before returning the NULL via the normal function return. Reviewed-by: 's avatarErkki Seppälä <erkki.seppala@vincit.fi> Signed-off-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: 's avatarUlrich Sibiller <uli42@gmx.de>
parent b7694b0b
......@@ -381,7 +381,7 @@ get_font_name(
XOC oc,
char *pattern)
{
char **list, *name, *prop_name;
char **list, *name;
int count;
XFontStruct *fs;
Display *dpy = oc->core.om->core.display;
......@@ -397,13 +397,7 @@ get_font_name(
fs = XLoadQueryFont(dpy, pattern);
if (fs == NULL) return NULL;
prop_name = get_prop_name(dpy, fs);
if (prop_name == NULL) return NULL;
name = (char*) Xmalloc(strlen(prop_name) + 1);
if (name)
strcpy(name, prop_name);
name = get_prop_name(dpy, fs);
XFreeFont(dpy, fs);
}
return name;
......
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