From 7475bc5d0af14477683498306f63eb422a263f79 Mon Sep 17 00:00:00 2001 From: David Maciejak Date: Fri, 3 Mar 2023 13:18:53 +0800 Subject: [PATCH] Coverity: fix util wmsetbg resource leak --- util/wmsetbg.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/util/wmsetbg.c b/util/wmsetbg.c index e5d1b157..dc747d04 100644 --- a/util/wmsetbg.c +++ b/util/wmsetbg.c @@ -505,7 +505,15 @@ static BackgroundTexture *parseTexture(RContext * rc, char *text) iheight = image->height; } - GETSTRORGOTO(val, tmp, 2, error); + /* cannot use GETSTRORGOTO() here + * as we have to free image in case of error */ + val = WMGetFromPLArray(texarray, 2); + if (!WMIsPLString(val)) { + wwarning("could not parse texture %s", text); + RReleaseImage(image); + goto error; + } + tmp = WMGetFromPLString(val); if (!XParseColor(dpy, DefaultColormap(dpy, scr), tmp, &color)) { wwarning("could not parse color %s in texture %s", tmp, text);