From e109aba3acbc32cecfd57477d47c2b2fc88c6752 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 13 Mar 2021 02:33:05 +0000 Subject: [PATCH] Treat an empty bool/duration/int/uint config field as undefined. --- src/configparser.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/configparser.cpp b/src/configparser.cpp index b68c52cbb..556442627 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -628,7 +628,7 @@ namespace long ConfigTag::getInt(const std::string &key, long def, long min, long max) { std::string result; - if(!readString(key, result)) + if(!readString(key, result) || result.empty()) return def; const char* res_cstr = result.c_str(); @@ -645,7 +645,7 @@ long ConfigTag::getInt(const std::string &key, long def, long min, long max) unsigned long ConfigTag::getUInt(const std::string& key, unsigned long def, unsigned long min, unsigned long max) { std::string result; - if (!readString(key, result)) + if (!readString(key, result) || result.empty()) return def; const char* res_cstr = result.c_str(); @@ -662,7 +662,7 @@ unsigned long ConfigTag::getUInt(const std::string& key, unsigned long def, unsi unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def, unsigned long min, unsigned long max) { std::string duration; - if (!readString(key, duration)) + if (!readString(key, duration) || duration.empty()) return def; unsigned long ret; @@ -691,7 +691,7 @@ double ConfigTag::getFloat(const std::string& key, double def, double min, doubl bool ConfigTag::getBool(const std::string &key, bool def) { std::string result; - if(!readString(key, result)) + if(!readString(key, result) || result.empty()) return def; if (stdalgo::string::equalsci(result, "yes") || stdalgo::string::equalsci(result, "true") || stdalgo::string::equalsci(result, "on") || result == "1") -- 2.39.2