gst-inspect: fix memory leak

With meson configure option: -Db_sanitize=address, the following
issue is seen while running the test "tools_gstinspect":

Running suite(s): gst-inspect

=================================================================
==20880==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 51 byte(s) in 9 object(s) allocated from:
    #0 0x7ffb4dbb0b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
    #1 0x7ffb4cdf1ab8 in g_malloc (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x51ab8)

SUMMARY: AddressSanitizer: 51 byte(s) leaked in 9 allocation(s).
0%: Checks: 1, Failures: 0, Errors: 1

GOptionEntry man page states that: "Please note that parsed arguments need to be freed separately (see GOptionEntry)."
Thus, free the 'min_version' string that has been allocated but never freed.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/572>
This commit is contained in:
Eero Nurkkala 2020-07-22 10:51:54 +03:00
parent a1b41b2b24
commit 083f73a01f

View file

@ -2049,8 +2049,10 @@ main (int argc, char *argv[])
&minver_micro) < 2) { &minver_micro) < 2) {
g_printerr ("Can't parse version '%s' passed to --atleast-version\n", g_printerr ("Can't parse version '%s' passed to --atleast-version\n",
min_version); min_version);
g_free (min_version);
return -1; return -1;
} }
g_free (min_version);
check_exists = TRUE; check_exists = TRUE;
} }