From 894d1c80a36a7c5f9fb396f5afb35f0414c9b8ef Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 31 May 2014 19:58:45 +0200 Subject: [PATCH] WPrefs: fix memory leak when saving settings (Coverity #50140 + #50157 + #50159) As pointed by Coverity, the string returned by 'WMGetTextFieldText' is allocated dynamically, so it must be freed when not needed anymore. Signed-off-by: Christophe CURIS --- WPrefs.app/Docks.c | 6 +++++- WPrefs.app/Focus.c | 1 + WPrefs.app/MouseSettings.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/WPrefs.app/Docks.c b/WPrefs.app/Docks.c index 7d54f30c..2a5265aa 100644 --- a/WPrefs.app/Docks.c +++ b/WPrefs.app/Docks.c @@ -292,7 +292,11 @@ static void storeData(_Panel *panel) int i; for (i = 0; i < 4; i++) { - SetStringForKey(WMGetTextFieldText(panel->autoDelayT[i]), auto_delay[i].key); + char *str; + + str = WMGetTextFieldText(panel->autoDelayT[i]); + SetStringForKey(str, auto_delay[i].key); + wfree(str); } for (i = 0; i < 3; i++) { diff --git a/WPrefs.app/Focus.c b/WPrefs.app/Focus.c index 3ee8ec94..ea4b20f2 100644 --- a/WPrefs.app/Focus.c +++ b/WPrefs.app/Focus.c @@ -138,6 +138,7 @@ static void storeData(_Panel * panel) if (sscanf(str, "%i", &i) != 1) i = 0; SetIntegerForKey(i, "RaiseDelay"); + free(str); SetBoolForKey(WMGetButtonSelected(panel->ignB), "IgnoreFocusClick"); SetBoolForKey(WMGetButtonSelected(panel->newB), "AutoFocus"); diff --git a/WPrefs.app/MouseSettings.c b/WPrefs.app/MouseSettings.c index cb767e6c..741bf97b 100644 --- a/WPrefs.app/MouseSettings.c +++ b/WPrefs.app/MouseSettings.c @@ -750,6 +750,7 @@ static void storeData(_Panel * panel) tmp = WMGetTextFieldText(panel->ddelaT); if (sscanf(tmp, "%i", &i) == 1 && i > 0) SetIntegerForKey(i, "DoubleClickTime"); + wfree(tmp); SetBoolForKey(WMGetButtonSelected(panel->disaB), "DisableWSMouseActions"); -- 2.11.4.GIT