diff options
author | peter1138 <peter1138@openttd.org> | 2009-02-07 00:29:35 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2009-02-07 00:29:35 +0000 |
commit | cd84ffb03617cbf41b28390d33fc402d2695a1da (patch) | |
tree | b7afcdd0ac21f0d8741bc86d71cbc468155d42f6 | |
parent | eb533138bc7ceb209d83884460240ca924868ce7 (diff) | |
download | openttd-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.
-rw-r--r-- | src/settings.cpp | 8 |
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(); } |