summaryrefslogtreecommitdiff
path: root/src/modules/sparkler
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-08-30 17:26:56 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-08-30 17:26:56 -0700
commitc91c9e5eeae06a7cbed94354d62c1281dc356407 (patch)
treea589ab8716cba804ec7c60e5882a2eec7f0033b7 /src/modules/sparkler
parent20d097ab1fe8ef5b62f4169f4353cc0074c27e4b (diff)
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...
Diffstat (limited to 'src/modules/sparkler')
-rw-r--r--src/modules/sparkler/sparkler.c10
1 files changed, 5 insertions, 5 deletions
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);
}
© All Rights Reserved