summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-05-17 13:05:44 +0000
committerpeter1138 <peter1138@openttd.org>2006-05-17 13:05:44 +0000
commitd40bc5a2649f7f5b7dda429614a290f6bbc1f69c (patch)
treec63f306640b4d3fe81270d36d0dd0b456b5bdb25
parent5a65e3301ef6698f42332cc5275af58fcd47460f (diff)
downloadopenttd-d40bc5a2649f7f5b7dda429614a290f6bbc1f69c.tar.xz
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
-rw-r--r--newgrf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/newgrf.c b/newgrf.c
index b17897829..c141b7342 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -1793,7 +1793,7 @@ static void VehicleNewName(byte *buf, int len)
for (; id < endid && len > 0; id++) {
size_t ofs = strlen(name) + 1;
- if (ofs < 128) {
+ if (ofs > 1 && ofs < 128) {
DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, name);
switch (feature) {
@@ -1857,7 +1857,13 @@ static void VehicleNewName(byte *buf, int len)
#endif
}
} else {
- DEBUG(grf, 7) ("VehicleNewName: Too long a name (%d)", ofs);
+ /* ofs is the string length + 1, so if the string is empty, ofs
+ * is 1 */
+ if (ofs == 1) {
+ DEBUG(grf, 7) ("VehicleNewName: Can't add empty name");
+ } else {
+ DEBUG(grf, 7) ("VehicleNewName: Too long a name (%d)", ofs);
+ }
}
name += ofs;
len -= ofs;