summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-05-01 15:33:42 +0000
committerfrosch <frosch@openttd.org>2012-05-01 15:33:42 +0000
commitec73ad11456bc1e98db2b65b6559d1a5dd626bfc (patch)
tree0425d4740f035587b9233402a3389e7f5512f20f
parentfdd05988b7598968c996070d03617b759c2d983c (diff)
downloadopenttd-ec73ad11456bc1e98db2b65b6559d1a5dd626bfc.tar.xz
(svn r24192) -Fix [FS#5153-ish]: Also use default value when reading an invalid integer setting value.
-rw-r--r--src/settings.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index 2b109e51e..13ae8141a 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -347,6 +347,12 @@ static const void *StringToVal(const SettingDescBase *desc, const char *orig_str
case SDT_NUMX: {
char *end;
size_t val = strtoul(str, &end, 0);
+ if (end == str) {
+ SetDParamStr(0, str);
+ SetDParamStr(1, desc->name);
+ ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_VALUE, WL_CRITICAL);
+ return desc->def;
+ }
if (*end != '\0') {
SetDParamStr(0, desc->name);
ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_TRAILING_CHARACTERS, WL_CRITICAL);