#3 - Fix null ptr deref when deleting platform while Mario pool is sparse
This commit is contained in:
@@ -241,6 +241,9 @@ SM64_LIB_FN void sm64_surface_object_delete( uint32_t objectId )
|
|||||||
// A mario standing on the platform that is being destroyed will have a pointer to freed memory if we don't clear it.
|
// A mario standing on the platform that is being destroyed will have a pointer to freed memory if we don't clear it.
|
||||||
for( int i = 0; i < s_mario_instance_pool.size; ++i )
|
for( int i = 0; i < s_mario_instance_pool.size; ++i )
|
||||||
{
|
{
|
||||||
|
if( s_mario_instance_pool.objects[i] == NULL )
|
||||||
|
continue;
|
||||||
|
|
||||||
struct GlobalState *state = ((struct MarioInstance *)s_mario_instance_pool.objects[ i ])->globalState;
|
struct GlobalState *state = ((struct MarioInstance *)s_mario_instance_pool.objects[ i ])->globalState;
|
||||||
if( state->mgMarioObject->platform == surfaces_object_get_transform_ptr( objectId ))
|
if( state->mgMarioObject->platform == surfaces_object_get_transform_ptr( objectId ))
|
||||||
state->mgMarioObject->platform = NULL;
|
state->mgMarioObject->platform = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user