From 788a51c1167fe760f905b865ea8830ac800b6653 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Tue, 20 May 2014 21:46:48 +0200 Subject: [PATCH] WMaker: fix memory leak in the window inspector when saving settings (Coverity #50175) As pointed by Coverity, there is one case where the string returned by WMGetTextFieldText could be left allocated. Signed-off-by: Christophe CURIS --- src/winspector.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/winspector.c b/src/winspector.c index 679c56f8..f1289ddd 100644 --- a/src/winspector.c +++ b/src/winspector.c @@ -488,11 +488,13 @@ static void saveSettings(WMWidget *button, void *client_data) /* The icon filename (if exists) */ icon_file = WMGetTextFieldText(panel->fileText); - if ((icon_file) && (icon_file[0] != 0)) { - value = WMCreatePLString(icon_file); - different |= insertAttribute(dict, winDic, AIcon, value, flags); - different2 |= insertAttribute(dict, appDic, AIcon, value, flags); - WMReleasePropList(value); + if (icon_file != NULL) { + if (icon_file[0] != '\0') { + value = WMCreatePLString(icon_file); + different |= insertAttribute(dict, winDic, AIcon, value, flags); + different2 |= insertAttribute(dict, appDic, AIcon, value, flags); + WMReleasePropList(value); + } wfree(icon_file); }