Mercurial > hg > openttd
changeset 3863:e887565da932 draft
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Wed, 17 May 2006 13:05:44 +0000 |
parents | 46119fe6c3b2 |
children | 942d54684994 |
files | newgrf.c |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/newgrf.c +++ b/newgrf.c @@ -1793,7 +1793,7 @@ 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 @@ #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;