From 225b41d163919def49bb59b628cd2173756fd1c7 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 13 May 2015 14:18:48 -0700 Subject: [PATCH] don't do dumb things with memory --- domain-server/src/DomainServerSettingsManager.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/domain-server/src/DomainServerSettingsManager.cpp b/domain-server/src/DomainServerSettingsManager.cpp index 963871c9b9..143c6e69c9 100644 --- a/domain-server/src/DomainServerSettingsManager.cpp +++ b/domain-server/src/DomainServerSettingsManager.cpp @@ -254,6 +254,7 @@ QJsonObject DomainServerSettingsManager::responseObjectForType(const QString& ty void DomainServerSettingsManager::updateSetting(const QString& key, const QJsonValue& newValue, QVariantMap& settingMap, const QJsonObject& settingDescription) { + if (newValue.isString()) { if (newValue.toString().isEmpty()) { // this is an empty value, clear it in settings variant so the default is sent @@ -360,7 +361,7 @@ void DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ settingsVariant[rootKey] = QVariantMap(); } - QVariantMap& thisMap = settingsVariant; + QVariantMap* thisMap = &settingsVariant; QJsonObject groupDescriptionObject; @@ -371,7 +372,7 @@ void DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ groupDescriptionObject = groupValue.toObject(); // change the map we will update to be the map for this group - thisMap = *reinterpret_cast(settingsVariant[rootKey].data()); + thisMap = reinterpret_cast(settingsVariant[rootKey].data()); break; } @@ -397,7 +398,7 @@ void DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ } if (!matchingDescriptionObject.isEmpty()) { - updateSetting(rootKey, rootValue, thisMap, matchingDescriptionObject); + updateSetting(rootKey, rootValue, *thisMap, matchingDescriptionObject); } else { qDebug() << "Setting for root key" << rootKey << "does not exist - cannot update setting."; } @@ -410,7 +411,7 @@ void DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ // if we matched the setting then update the value if (!matchingDescriptionObject.isEmpty()) { QJsonValue settingValue = rootValue.toObject()[settingKey]; - updateSetting(settingKey, settingValue, thisMap, matchingDescriptionObject); + updateSetting(settingKey, settingValue, *thisMap, matchingDescriptionObject); } else { qDebug() << "Could not find description for setting" << settingKey << "in group" << rootKey << "- cannot update setting.";