From 5080a29341b0d12f1747afb6fa52de10b96503a4 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 2 May 2015 01:08:29 -0700 Subject: [PATCH] Util: Fix a null-pointer issue when attempting to delete a key --- CHANGES | 1 + src/util/configuration.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index b5252d806..bd71f8b81 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,7 @@ Bugfixes: - Debugger: Fix boundary conditions in tab completion - Video: Fix an issue with very long filenames - SDL: Fix boundary conditions for joystick adjustments + - Util: Fix a null-pointer issue when attempting to delete a key Misc: - Qt: Show multiplayer numbers in window title - Qt: Solar sensor can have shortcuts set diff --git a/src/util/configuration.c b/src/util/configuration.c index f087aec82..d9ccdac41 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -53,10 +53,14 @@ void ConfigurationSetValue(struct Configuration* configuration, const char* sect struct Table* currentSection = &configuration->root; if (section) { currentSection = HashTableLookup(&configuration->sections, section); - if (!currentSection && value) { - currentSection = malloc(sizeof(*currentSection)); - HashTableInit(currentSection, 0, _sectionDeinit); - HashTableInsert(&configuration->sections, section, currentSection); + if (!currentSection) { + if (value) { + currentSection = malloc(sizeof(*currentSection)); + HashTableInit(currentSection, 0, _sectionDeinit); + HashTableInsert(&configuration->sections, section, currentSection); + } else { + return; + } } } if (value) {