summaryrefslogtreecommitdiff
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
commit645e8c4b69472e6b246e311b26fe808d43696d4d (patch)
treeb7afcdd0ac21f0d8741bc86d71cbc468155d42f6
parentb02cbf88444509a20b2532a31509f57c8eed300a (diff)
downloadopenttd-645e8c4b69472e6b246e311b26fe808d43696d4d.tar.xz
(svn r15385) -Fix: Saving of char* to configuration file did not work due to incorrect parameter order and no handling of NULL.
-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();
}