diff options
author | Peter Powell <petpow@saberuk.com> | 2018-04-14 16:11:57 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-04-16 15:29:58 +0100 |
commit | 9b8dc77585ada328a306bc12bb9827f083e7cf93 (patch) | |
tree | 13f89459bd95cca9fcd23ba2a3cd36e17f85b361 /src/configparser.cpp | |
parent | 780dda83ba3857bc3c330d4b5d38bb251a9d879b (diff) |
Add range checking to ConfigTag::getFloat.
Diffstat (limited to 'src/configparser.cpp')
-rw-r--r-- | src/configparser.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp index 5ee86c811..8a3042eba 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -524,12 +524,15 @@ unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def, return ret; } -double ConfigTag::getFloat(const std::string &key, double def) +double ConfigTag::getFloat(const std::string& key, double def, double min, double max) { std::string result; if (!readString(key, result)) return def; - return strtod(result.c_str(), NULL); + + double res = strtod(result.c_str(), NULL); + CheckRange(tag, key, res, def, min, max); + return res; } bool ConfigTag::getBool(const std::string &key, bool def) |