Fix crash when surfaces fail to allocate

This commit is contained in:
MysterD 2022-02-27 00:53:58 -08:00
parent 86b36eb867
commit ab698e976b
2 changed files with 3 additions and 0 deletions

View File

@ -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);

View File

@ -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;