mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
This commit is contained in:
parent
7fb02749ac
commit
bb1a95d149
8
newgrf.c
8
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) {
|
||||
@ -1856,9 +1856,15 @@ static void VehicleNewName(byte *buf, int len)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
/* 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user