From dc2a991e219fa5c06a1294cac256fa44e7c9206a Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 31 May 2014 19:58:41 +0200 Subject: [PATCH] WPrefs: fix possible crash when saving mouse modifier (Coverity #50098) As pointed by Coverity, there is a possible NULL pointer dereference in the code that extracts the selected modifier (from a popup button list). The code assumes that there is always a space between the core name of the modifier (which is used for saving) and the more user friendly name. This is true if the list could be successfully generated in fillModifierPopUp, but it may not be the case if that function has to fall-back to the default list (XGetModifierMaping failure). Signed-off-by: Christophe CURIS --- WPrefs.app/MouseSettings.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WPrefs.app/MouseSettings.c b/WPrefs.app/MouseSettings.c index 31d467de..cb767e6c 100644 --- a/WPrefs.app/MouseSettings.c +++ b/WPrefs.app/MouseSettings.c @@ -768,7 +768,8 @@ static void storeData(_Panel * panel) tmp = WMGetPopUpButtonItem(panel->grabP, WMGetPopUpButtonSelectedItem(panel->grabP)); tmp = wstrdup(tmp); p = strchr(tmp, ' '); - *p = 0; + if (p != NULL) + *p = '\0'; SetStringForKey(tmp, "ModifierKey");