summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-02-07 00:29:35 +0000
committerpeter1138 <peter1138@openttd.org>2009-02-07 00:29:35 +0000
commitcd84ffb03617cbf41b28390d33fc402d2695a1da (patch)
treeb7afcdd0ac21f0d8741bc86d71cbc468155d42f6 /src
parenteb533138bc7ceb209d83884460240ca924868ce7 (diff)
downloadopenttd-cd84ffb03617cbf41b28390d33fc402d2695a1da.tar.xz
(svn r15385) -Fix: Saving of char* to configuration file did not work due to incorrect parameter order and no handling of NULL.
Diffstat (limited to 'src')
-rw-r--r--src/settings.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index 9a47d0840..072f04322 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -567,7 +567,13 @@ static void ini_save_settings(IniFile *ini, const SettingDesc *sd, const char *g
case SLE_VAR_STRB: strcpy(buf, (char*)ptr); break;
case SLE_VAR_STRBQ:seprintf(buf, lastof(buf), "\"%s\"", (char*)ptr); break;
case SLE_VAR_STR: strcpy(buf, *(char**)ptr); break;
- case SLE_VAR_STRQ: seprintf(buf, "\"%s\"", lastof(buf), *(char**)ptr); break;
+ case SLE_VAR_STRQ:
+ if (*(char**)ptr == NULL) {
+ buf[0] = '\0';
+ } else {
+ seprintf(buf, lastof(buf), "\"%s\"", *(char**)ptr);
+ }
+ break;
case SLE_VAR_CHAR: buf[0] = *(char*)ptr; buf[1] = '\0'; break;
default: NOT_REACHED();
}