From 7aa4c62d92e17347cc331316a0d4c838e133e6a9 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 19 Aug 2008 21:14:29 +0200 Subject: Fix missing initializing in BarSettingsDestroy which caused segfault Thereby avoid freeing a NULL pointer --- src/settings.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/settings.c') diff --git a/src/settings.c b/src/settings.c index e756364..663a21a 100644 --- a/src/settings.c +++ b/src/settings.c @@ -63,13 +63,17 @@ void BarSettingsInit (BarSettings_t *settings) { } void BarSettingsDestroy (BarSettings_t *settings) { - BarKeyShortcut_t *curShortcut, *lastShortcut; + BarKeyShortcut_t *curShortcut = settings->keys, *lastShortcut; while (curShortcut != NULL) { lastShortcut = curShortcut; curShortcut = curShortcut->next; - free (lastShortcut->description); - free (lastShortcut->configKey); + if (lastShortcut->description != NULL) { + free (lastShortcut->description); + } + if (lastShortcut->configKey != NULL) { + free (lastShortcut->configKey); + } free (lastShortcut); } free (settings->controlProxy); -- cgit v1.2.3