diff --git a/libs/ecs/ecs.c b/libs/ecs/ecs.c index af9870219..291271bd1 100644 --- a/libs/ecs/ecs.c +++ b/libs/ecs/ecs.c @@ -46,6 +46,9 @@ ECS_NewRegistry (void) VISIBLE void ECS_DelRegistry (ecs_registry_t *registry) { + if (!registry) { + return; + } registry->locked = 1; for (uint32_t i = 0; i < registry->components.size; i++) { __auto_type comp = ®istry->components.a[i]; diff --git a/libs/scene/entity.c b/libs/scene/entity.c index 8d88ea8c1..e984865f6 100644 --- a/libs/scene/entity.c +++ b/libs/scene/entity.c @@ -52,6 +52,9 @@ EntQueue_New (int num_queues) void EntQueue_Delete (entqueue_t *queue) { + if (!queue) { + return; + } for (int i = 0; i < queue->num_queues; i++) { DARRAY_CLEAR (&queue->ent_queues[i]); } diff --git a/libs/util/dstring.c b/libs/util/dstring.c index 035a5a42e..dc478b8c2 100644 --- a/libs/util/dstring.c +++ b/libs/util/dstring.c @@ -83,6 +83,9 @@ dstring_new (void) VISIBLE void dstring_delete (dstring_t *dstr) { + if (!dstr) { + return; + } if (dstr->str) dstr->mem->free (dstr->mem->data, dstr->str); dstr->mem->free (dstr->mem->data, dstr); diff --git a/libs/util/hash.c b/libs/util/hash.c index 1fb9cb643..28bf9a93f 100644 --- a/libs/util/hash.c +++ b/libs/util/hash.c @@ -283,6 +283,9 @@ Hash_SetHashCompare (hashtab_t *tab, uintptr_t (*gh)(const void*,void*), VISIBLE void Hash_DelTable (hashtab_t *tab) { + if (!tab) { + return; + } Hash_FlushTable (tab); free (tab); } diff --git a/libs/video/renderer/glsl/glsl_draw.c b/libs/video/renderer/glsl/glsl_draw.c index 1ee895fd7..ca11b1689 100644 --- a/libs/video/renderer/glsl/glsl_draw.c +++ b/libs/video/renderer/glsl/glsl_draw.c @@ -168,6 +168,10 @@ make_glpic (const char *name, qpic_t *p) static void pic_free (qpic_t *pic) { + if (!pic) { + return; + } + subpic_t *subpic = *(subpic_t **) pic->data; GLSL_SubpicDelete (subpic); diff --git a/libs/video/renderer/glsl/glsl_textures.c b/libs/video/renderer/glsl/glsl_textures.c index 657ffa3f6..a33cb86fa 100644 --- a/libs/video/renderer/glsl/glsl_textures.c +++ b/libs/video/renderer/glsl/glsl_textures.c @@ -394,6 +394,9 @@ GLSL_ScrapClear (scrap_t *scrap) void GLSL_DestroyScrap (scrap_t *scrap) { + if (!scrap) { + return; + } scrap_t **s; for (s = &scrap_list; *s; s = &(*s)->next) { diff --git a/libs/video/renderer/r_scrap.c b/libs/video/renderer/r_scrap.c index 591720a8f..3c34f3670 100644 --- a/libs/video/renderer/r_scrap.c +++ b/libs/video/renderer/r_scrap.c @@ -65,6 +65,9 @@ R_ScrapInit (rscrap_t *scrap, int width, int height) VISIBLE void R_ScrapDelete (rscrap_t *scrap) { + if (!scrap) { + return; + } R_ScrapClear (scrap); VRect_Delete (scrap->free_rects); } diff --git a/libs/video/targets/vid.c b/libs/video/targets/vid.c index cca24b2af..388baee6d 100644 --- a/libs/video/targets/vid.c +++ b/libs/video/targets/vid.c @@ -328,10 +328,14 @@ VID_shutdown (void *data) free (viddef.palette); free (viddef.palette32); - DARRAY_CLEAR (viddef.onPaletteChanged); - DARRAY_CLEAR (viddef.onVidResize); - free (viddef.onPaletteChanged); - free (viddef.onVidResize); + if (viddef.onPaletteChanged) { + DARRAY_CLEAR (viddef.onPaletteChanged); + free (viddef.onPaletteChanged); + } + if (viddef.onVidResize) { + DARRAY_CLEAR (viddef.onVidResize); + free (viddef.onVidResize); + } } VISIBLE void