(svn r11077) [0.5] -Fix: Possible NULL pointer dereference.

This commit is contained in:
rubidium 2007-09-09 22:35:21 +00:00
parent c87722e428
commit d2258280bf
7 changed files with 7 additions and 7 deletions

View File

@ -372,7 +372,7 @@ int32 CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
StringID str;
if (!IsEngineIndex(p1) || _cmd_text[0] == '\0') return CMD_ERROR;
if (!IsEngineIndex(p1) || _cmd_text == NULL || _cmd_text[0] == '\0') return CMD_ERROR;
str = AllocateNameUnique(_cmd_text, 0);
if (str == 0) return CMD_ERROR;

View File

@ -187,7 +187,7 @@ int32 CmdChangeCompanyName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
StringID str;
Player *p;
if (_cmd_text[0] == '\0') return CMD_ERROR;
if (_cmd_text == NULL || _cmd_text[0] == '\0') return CMD_ERROR;
str = AllocateNameUnique(_cmd_text, 4);
if (str == 0) return CMD_ERROR;

View File

@ -151,7 +151,7 @@ int32 CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* If _cmd_text 0 means the new text for the sign is non-empty.
* So rename the sign. If it is empty, it has no name, so delete it */
if (_cmd_text[0] != '\0') {
if (_cmd_text != NULL && _cmd_text[0] != '\0') {
/* Create the name */
StringID str = AllocateName(_cmd_text, 0);
if (str == 0) return CMD_ERROR;

View File

@ -2645,7 +2645,7 @@ int32 CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
StringID str;
Station *st;
if (!IsValidStationID(p1) || _cmd_text[0] == '\0') return CMD_ERROR;
if (!IsValidStationID(p1) || _cmd_text == NULL || _cmd_text[0] == '\0') return CMD_ERROR;
st = GetStation(p1);
if (!CheckOwnership(st->owner)) return CMD_ERROR;

View File

@ -1373,7 +1373,7 @@ int32 CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
StringID str;
Town *t;
if (!IsValidTownID(p1) || _cmd_text[0] == '\0') return CMD_ERROR;
if (!IsValidTownID(p1) || _cmd_text == NULL || _cmd_text[0] == '\0') return CMD_ERROR;
t = GetTown(p1);

View File

@ -2633,7 +2633,7 @@ int32 CmdNameVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
Vehicle *v;
StringID str;
if (!IsValidVehicleID(p1) || _cmd_text[0] == '\0') return CMD_ERROR;
if (!IsValidVehicleID(p1) || _cmd_text == NULL || _cmd_text[0] == '\0') return CMD_ERROR;
v = GetVehicle(p1);

View File

@ -319,7 +319,7 @@ int32 CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
wp = GetWaypoint(p1);
if (!CheckTileOwnership(wp->xy)) return CMD_ERROR;
if (_cmd_text[0] != '\0') {
if (_cmd_text != NULL && _cmd_text[0] != '\0') {
StringID str = AllocateNameUnique(_cmd_text, 0);
if (str == 0) return CMD_ERROR;