shithub: libgraphics

Download patch

ref: e05e6c6e71fe60cf663ab563f75b17365ad94665
parent: 930e09a2ea12275cf2e04577a170a2be342db045
author: rodri <rgl@antares-labs.eu>
date: Wed Apr 3 12:17:48 EDT 2024

add trivial nil checks to some of the cleanup procedures.

--- a/scene.c
+++ b/scene.c
@@ -117,6 +117,8 @@
 void
 delmodel(Model *m)
 {
+	if(m == nil)
+		return;
 	if(m->obj != nil)
 		objfree(m->obj);
 	if(m->tex != nil)
@@ -146,7 +148,10 @@
 void
 delentity(Entity *e)
 {
-	delmodel(e->mdl);
+	if(e == nil)
+		return;
+	if(e->mdl != nil)
+		delmodel(e->mdl);
 	free(e);
 }
 
@@ -176,6 +181,8 @@
 void
 delscene(Scene *s)
 {
+	if(s == nil)
+		return;
 	clearscene(s);
 	free(s->name);
 	free(s);
--- a/viewport.c
+++ b/viewport.c
@@ -52,6 +52,8 @@
 void
 rmviewport(Viewport *v)
 {
+	if(v == nil)
+		return;
 	rmfbctl(v->fbctl);
 	free(v);
 }