From 54550ebb2a1fc504406b199550b8e023ef2c9517 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 1 Feb 2011 12:30:56 +0200 Subject: XDefaultOMIF.c: Fix memory leaks in get_font_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Erkki Seppälä Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/XDefaultOMIF.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'nx-X11/lib/X11') diff --git a/nx-X11/lib/X11/XDefaultOMIF.c b/nx-X11/lib/X11/XDefaultOMIF.c index dbadd90aa..6975aa806 100644 --- a/nx-X11/lib/X11/XDefaultOMIF.c +++ b/nx-X11/lib/X11/XDefaultOMIF.c @@ -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; -- cgit v1.2.3