From a6340288f8259cc96b5af05bce3612dbf4f9b7e4 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <lars@6xq.net>
Date: Sat, 4 Dec 2010 20:57:00 +0100
Subject: Show default icons if config file is missing.

Bug introduced by 2b31c97de6fa541719cd26f9a61053cfc0e71203. "(null)" was
shown instead of "<3" and "</3".
---
 src/settings.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/settings.c b/src/settings.c
index 64b56c4..259c9f0 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -118,6 +118,8 @@ void BarSettingsRead (BarSettings_t *settings) {
 	settings->history = 5;
 	settings->sortOrder = BAR_SORT_NAME_AZ;
 	memcpy (settings->keys, defaultKeys, sizeof (defaultKeys));
+	settings->loveIcon = strdup ("<3");
+	settings->banIcon = strdup ("</3");
 
 	BarGetXdgConfigDir (PACKAGE "/config", configfile, sizeof (configfile));
 	if ((configfd = fopen (configfile, "r")) == NULL) {
@@ -180,8 +182,10 @@ void BarSettingsRead (BarSettings_t *settings) {
 				}
 			}
 		} else if (streq ("love_icon", key)) {
+			free (settings->loveIcon);
 			settings->loveIcon = strdup (val);
 		} else if (streq ("ban_icon", key)) {
+			free (settings->banIcon);
 			settings->banIcon = strdup (val);
 		}
 	}
@@ -194,13 +198,5 @@ void BarSettingsRead (BarSettings_t *settings) {
 		}
 	}
 
-	/* use default strings */
-	if (settings->loveIcon == NULL) {
-		settings->loveIcon = strdup ("<3");
-	}
-	if (settings->banIcon == NULL) {
-		settings->banIcon = strdup ("</3");
-	}
-
 	fclose (configfd);
 }
-- 
cgit v1.2.3