summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2014-04-24 18:58:47 +0000
committerfrosch <frosch@openttd.org>2014-04-24 18:58:47 +0000
commitd71cc434e40c73d6557529f58287c5bbc5451114 (patch)
tree41af589796f4bceb1d54cabc3a2780e0fbcbbc65 /src
parent2e493fa806bb54bf48a5f47729a9c5a01afdd100 (diff)
downloadopenttd-d71cc434e40c73d6557529f58287c5bbc5451114.tar.xz
(svn r26504) -Fix (r26499): Obiwan and his gang.
Diffstat (limited to 'src')
-rw-r--r--src/game/game_text.cpp2
-rw-r--r--src/ini_load.cpp12
2 files changed, 7 insertions, 7 deletions
diff --git a/src/game/game_text.cpp b/src/game/game_text.cpp
index bfff460ae..1717dcf9a 100644
--- a/src/game/game_text.cpp
+++ b/src/game/game_text.cpp
@@ -66,7 +66,7 @@ void NORETURN CDECL strgen_fatal(const char *s, ...)
*/
LanguageStrings::LanguageStrings(const char *language, const char *end)
{
- this->language = stredup(language, end - 1);
+ this->language = stredup(language, end != NULL ? end - 1 : NULL);
}
/** Free everything. */
diff --git a/src/ini_load.cpp b/src/ini_load.cpp
index 8816f66c4..f90953a10 100644
--- a/src/ini_load.cpp
+++ b/src/ini_load.cpp
@@ -167,7 +167,7 @@ IniGroup *IniLoadFile::GetGroup(const char *name, size_t len, bool create_new)
if (!create_new) return NULL;
/* otherwise make a new one */
- IniGroup *group = new IniGroup(this, name, name + len);
+ IniGroup *group = new IniGroup(this, name, name + len - 1);
group->comment = strdup("\n");
return group;
}
@@ -264,7 +264,7 @@ void IniLoadFile::LoadFromDisk(const char *filename, Subdirectory subdir)
s++; // skip [
group = new IniGroup(this, s, e - 1);
if (comment_size != 0) {
- group->comment = stredup(comment, comment + comment_size);
+ group->comment = stredup(comment, comment + comment_size - 1);
comment_size = 0;
}
} else if (group != NULL) {
@@ -272,7 +272,7 @@ void IniLoadFile::LoadFromDisk(const char *filename, Subdirectory subdir)
/* A sequence group, use the line as item name without further interpretation. */
IniItem *item = new IniItem(group, buffer, e - 1);
if (comment_size) {
- item->comment = stredup(comment, comment + comment_size);
+ item->comment = stredup(comment, comment + comment_size - 1);
comment_size = 0;
}
continue;
@@ -290,7 +290,7 @@ void IniLoadFile::LoadFromDisk(const char *filename, Subdirectory subdir)
/* it's an item in an existing group */
IniItem *item = new IniItem(group, s, t - 1);
if (comment_size != 0) {
- item->comment = stredup(comment, comment + comment_size);
+ item->comment = stredup(comment, comment + comment_size - 1);
comment_size = 0;
}
@@ -306,7 +306,7 @@ void IniLoadFile::LoadFromDisk(const char *filename, Subdirectory subdir)
*e = '\0';
/* If the value was not quoted and empty, it must be NULL */
- item->value = (!quoted && e == t) ? NULL : stredup(t, e);
+ item->value = (!quoted && e == t) ? NULL : stredup(t);
if (item->value != NULL) str_validate(item->value, item->value + strlen(item->value));
} else {
/* it's an orphan item */
@@ -315,7 +315,7 @@ void IniLoadFile::LoadFromDisk(const char *filename, Subdirectory subdir)
}
if (comment_size > 0) {
- this->comment = stredup(comment, comment + comment_size);
+ this->comment = stredup(comment, comment + comment_size - 1);
comment_size = 0;
}