Add UBFIX for null derefs in sub_8088950
This commit is contained in:
@@ -797,15 +797,33 @@ bool8 CameraMove(int x, int y)
|
|||||||
struct MapConnection *sub_8088950(u8 direction, int x, int y)
|
struct MapConnection *sub_8088950(u8 direction, int x, int y)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
struct MapConnection *connection;
|
|
||||||
int i;
|
int i;
|
||||||
count = gMapHeader.connections->count;
|
struct MapConnection *connection;
|
||||||
connection = gMapHeader.connections->connections;
|
const struct MapConnections *connections = gMapHeader.connections;
|
||||||
|
// UB: Multiple possible null dereferences
|
||||||
|
#ifdef UBFIX
|
||||||
|
if (connections != NULL)
|
||||||
|
{
|
||||||
|
count = connections->count;
|
||||||
|
connection = connections->connections;
|
||||||
|
if (connection != NULL)
|
||||||
|
{
|
||||||
|
for (i = 0; i < count; i++, connection++)
|
||||||
|
{
|
||||||
|
if (connection->direction == direction && sub_80889A8(direction, x, y, connection) == TRUE)
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
count = connections->count;
|
||||||
|
connection = connections->connections;
|
||||||
for (i = 0; i < count; i++, connection++)
|
for (i = 0; i < count; i++, connection++)
|
||||||
{
|
{
|
||||||
if (connection->direction == direction && sub_80889A8(direction, x, y, connection) == TRUE)
|
if (connection->direction == direction && sub_80889A8(direction, x, y, connection) == TRUE)
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user