From 6d492db9486a027a2612f73221facf96ceac6335 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 17 Nov 2021 12:43:46 +0100 Subject: [PATCH] impl-module: don't leak filename When dlopen fails, don't leak the filename. Fix indentation. --- src/pipewire/impl-module.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pipewire/impl-module.c b/src/pipewire/impl-module.c index d7e59e2a8..0b7d35467 100644 --- a/src/pipewire/impl-module.c +++ b/src/pipewire/impl-module.c @@ -184,15 +184,18 @@ pw_context_load_module(struct pw_context *context, while ((p = pw_split_walk(module_dir, ":", &len, &state))) { if ((res = spa_scnprintf(path_part, sizeof(path_part), "%.*s", (int)len, p)) > 0) { filename = find_module(path_part, name, 8); - if (filename != NULL) { - pw_log_debug("trying to load module: %s (%s) args(%s)", name, filename, args); + if (filename != NULL) { + pw_log_debug("trying to load module: %s (%s) args(%s)", name, filename, args); - hnd = dlopen(filename, RTLD_NOW | RTLD_LOCAL); - if (hnd != NULL) - break; + hnd = dlopen(filename, RTLD_NOW | RTLD_LOCAL); + if (hnd != NULL) + break; + + free(filename); + filename = NULL; + } } } -} if (filename == NULL) goto error_not_found;