mirror of https://github.com/OpenTTD/OpenTTD
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
parent
5a65e3301e
commit
d40bc5a264
10
newgrf.c
10
newgrf.c
|
@ -1793,7 +1793,7 @@ static void VehicleNewName(byte *buf, int len)
|
||||||
for (; id < endid && len > 0; id++) {
|
for (; id < endid && len > 0; id++) {
|
||||||
size_t ofs = strlen(name) + 1;
|
size_t ofs = strlen(name) + 1;
|
||||||
|
|
||||||
if (ofs < 128) {
|
if (ofs > 1 && ofs < 128) {
|
||||||
DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, name);
|
DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, name);
|
||||||
|
|
||||||
switch (feature) {
|
switch (feature) {
|
||||||
|
@ -1857,7 +1857,13 @@ static void VehicleNewName(byte *buf, int len)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
name += ofs;
|
||||||
len -= ofs;
|
len -= ofs;
|
||||||
|
|
Loading…
Reference in New Issue