From da606f5ce2b249e5a4f15422a1a6ee0ab55e452b Mon Sep 17 00:00:00 2001 From: Jaideep Sharma Date: Tue, 6 Sep 2022 16:33:45 +0530 Subject: tinycompress: free dynamic memory after use Release dynamically allocated memory for open_fn once dlsym is done to avoid memory leaks. CRs-Fixed: 3285530 Change-Id: I5b22a8db3c76a9134d4d0946ec33d8a0c4226bac --- compress_plugin.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/compress_plugin.c b/compress_plugin.c index 22f8f11..ac54f6c 100644 --- a/compress_plugin.c +++ b/compress_plugin.c @@ -384,17 +384,18 @@ static int compress_plug_open(unsigned int card, unsigned int device, strlcat(open_fn, "_open", open_fn_size); plug_data->plugin_open_fn = dlsym(dl_hdl, open_fn); + free(open_fn); if (!plug_data->plugin_open_fn) { fprintf(stderr, "%s: dlsym to open fn failed, err = '%s'\n", __func__, dlerror()); - goto err_dlsym; + goto err_open_fn; } rc = plug_data->plugin_open_fn(&plug_data->plugin, card, device, flags); if (rc) { fprintf(stderr, "%s: failed to open plugin\n", __func__); - goto err_dlsym; + goto err_open_fn; } /* Call snd-card-def to get card and compress nodes */ @@ -412,8 +413,6 @@ static int compress_plug_open(unsigned int card, unsigned int device, return 0; -err_dlsym: - free(open_fn); err_open_fn: dlclose(dl_hdl); err_get_lib: -- cgit v1.2.3