From cd8698c4b0480c2b0d631759b952c28def3cc28d Mon Sep 17 00:00:00 2001 From: NightlyFox Date: Thu, 27 Sep 2018 23:25:07 -0500 Subject: [PATCH] added null checks to theme.c, removed and added newline in language.c --- common/language.c | 1 - common/theme.c | 15 ++++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/common/language.c b/common/language.c index 7df10e3..1f99845 100644 --- a/common/language.c +++ b/common/language.c @@ -319,7 +319,6 @@ const char* const g_strings[StrId_Max][16] = STR_TW("应用"), }, - [StrId_ThemeMenu] = { STR_EN("Theme Menu"), diff --git a/common/theme.c b/common/theme.c index 6fc60bf..ad0a6e5 100644 --- a/common/theme.c +++ b/common/theme.c @@ -176,13 +176,18 @@ void SetThemePathToConfig(const char* themePath) { if(good_cfg) { group = config_lookup(&cfg, "hbmenuConfig"); - setting = config_setting_lookup(group, "themePath"); - config_setting_set_string(setting, themePath); + if(group != NULL) + setting = config_setting_lookup(group, "themePath"); + if(setting != NULL) + config_setting_set_string(setting, themePath); } else { root = config_root_setting(&cfg); - group = config_setting_add(root, "hbmenuConfig", CONFIG_TYPE_GROUP); - setting = config_setting_add(group, "themePath", CONFIG_TYPE_STRING); - config_setting_set_string(setting, themePath); + if(root != NULL) + group = config_setting_add(root, "hbmenuConfig", CONFIG_TYPE_GROUP); + if(group != NULL) + setting = config_setting_add(group, "themePath", CONFIG_TYPE_STRING); + if(setting != NULL) + config_setting_set_string(setting, themePath); } if(!config_write_file(&cfg, settingPath)) {