diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index 3bf7a9c4..0645f311 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -71,6 +71,7 @@ static struct Surface *alloc_surface(void) { // we, um... // Perhaps originally just debug feedback? if (gSurfacesAllocated >= sSurfacePoolSize) { + return NULL; } surface->type = 0; @@ -363,6 +364,7 @@ static struct Surface *read_surface_data(s16 *vertexData, s16 **vertexIndices) { nz *= mag; surface = alloc_surface(); + if (surface == NULL) { return NULL; } vec3s_copy(surface->prevVertex1, surface->vertex1); vec3s_copy(surface->prevVertex2, surface->vertex2); diff --git a/src/pc/lua/smlua_obj_utils.c b/src/pc/lua/smlua_obj_utils.c index 38770941..74dfba9b 100644 --- a/src/pc/lua/smlua_obj_utils.c +++ b/src/pc/lua/smlua_obj_utils.c @@ -22,6 +22,7 @@ static struct Object* spawn_object_internal(enum BehaviorId behaviorId, enum Mod } struct Object* obj = spawn_object(gMarioStates[0].marioObj, loadedModelId, behavior); + if (obj == NULL) { LOG_ERROR("failed to allocate object"); return NULL;