From 3427eefac9cf38ac3fa2635c69bb3f0693700cf8 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 24 Apr 2022 21:16:37 -0700 Subject: *: free setup allocations via til_setup_free() This should plug a bulk of the setup leaks. Some of the free_funcs still need to be changed to bespoke ones in modules that allocate nested things in their respective setup, so those are still leaking the nested things which are usually just a small strdup of some kind. --- src/modules/rtv/rtv.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/modules/rtv/rtv.c') diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index 06dfd90..08f4b8a 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -409,8 +409,11 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting til_get_modules(&modules, &n_modules); tokchannels = strdup(channels); - if (!tokchannels) + if (!tokchannels) { + til_setup_free(&setup->til_setup); + return -ENOMEM; + } channel = strtok(tokchannels, ":"); do { @@ -422,12 +425,16 @@ static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting break; } - if (i >= n_modules) + if (i >= n_modules) { + til_setup_free(&setup->til_setup); + return -EINVAL; + } new = realloc(setup, sizeof(*setup) + n * sizeof(setup->channels[0])); if (!new) { - free(setup); + til_setup_free(&setup->til_setup); + return -ENOMEM; } -- cgit v1.2.3