From c91c9e5eeae06a7cbed94354d62c1281dc356407 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 30 Aug 2023 17:26:56 -0700 Subject: modules/*: til_module_context_free() error paths Several modules still had vestigial ad-hoc free() cleanups on error paths in their create_context(). Largely mechanical change of replacing those with til_module_context_free() which is more appropriate, since the til_module_context_t holds a reference on the setup. A plain free() will leak that reference. But it's only on create_context() failures which are uncommon, so this was in practice mostly harmless... --- src/modules/sparkler/sparkler.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/modules/sparkler') diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c index 76f1c9b..e37257c 100644 --- a/src/modules/sparkler/sparkler.c +++ b/src/modules/sparkler/sparkler.c @@ -50,10 +50,8 @@ static til_module_context_t * sparkler_create_context(const til_module_t *module .show_bsp_matches_affected_only = ((sparkler_setup_t *)setup)->show_bsp_matches_affected_only, .seedp = &ctxt->til_module_context.seed, }); - if (!ctxt->particles) { - free(ctxt); - return NULL; - } + if (!ctxt->particles) + return til_module_context_free(&ctxt->til_module_context); particles_add_particles(ctxt->particles, NULL, &simple_ops, INIT_PARTS, 0); @@ -65,7 +63,9 @@ static void sparkler_destroy_context(til_module_context_t *context) { sparkler_context_t *ctxt = (sparkler_context_t *)context; - particles_free(ctxt->particles); + if (ctxt->particles) + particles_free(ctxt->particles); + free(ctxt); } -- cgit v1.2.3