From c088d6f7a45024e9c3f812b2fe7b536797a44ef0 Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 21 Mar 2022 12:29:30 -0700 Subject: [PATCH] Fixed crash in find_floor_from_list() --- src/engine/surface_collision.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index 77bb72ed3..4f4208f51 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -425,6 +425,7 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32 // Iterate through the list of floors until there are no more floors. while (surfaceNode != NULL) { surf = surfaceNode->surface; + if (surf == NULL) { break; } surfaceNode = surfaceNode->next; interpolate = gInterpolatingSurfaces && surf->modifiedTimestamp == gGlobalTimer; @@ -521,7 +522,10 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32 continue; } - *pheight = height; + if (pheight != NULL) { + *pheight = height; + } + if (interpolate) { static struct Surface s; s.type = surf->type;