]> sigrok.org Git - libsigrokdecode.git/commitdiff
Fix memory leak in print_searchpaths()
authorJon Burgess <redacted>
Sun, 14 Oct 2018 17:55:47 +0000 (18:55 +0100)
committerUwe Hermann <redacted>
Sun, 21 Oct 2018 14:39:33 +0000 (16:39 +0200)
==175453== 522 bytes in 8 blocks are definitely lost in loss record 2,923 of 3,201
==175453==    at 0x4C2EBAB: malloc (vg_replace_malloc.c:299)
==175453==    by 0x59E9BB5: PyObject_Malloc (in /usr/lib64/libpython3.6m.so.1.0)
==175453==    by 0x5A35A76: PyBytes_FromStringAndSize (in /usr/lib64/libpython3.6m.so.1.0)
==175453==    by 0x4E3FA6E: print_searchpaths (srd.c:173)
==175453==    by 0x4E3FA6E: srd_init (srd.c:287)
==175453==    by 0x4034BE: test_session_reset_nodata (session.c:238)
==175453==    by 0x53E51D5: srunner_run_tagged (in /usr/lib64/libcheck.so.0.0.0)
==175453==    by 0x401237: main (main.c:51)

srd.c

diff --git a/srd.c b/srd.c
index 248d8e5a69e3793450f50127a47e8a7563b416e0..22f47fcf26a869ad8856e90b6f7f34bc76be5741 100644 (file)
--- a/srd.c
+++ b/srd.c
@@ -172,6 +172,7 @@ static int print_searchpaths(void)
                py_path = PyList_GetItem(py_paths, i);
                py_bytes = PyUnicode_AsUTF8String(py_path);
                g_string_append_printf(s, " - %s\n", PyBytes_AsString(py_bytes));
+               Py_DECREF(py_bytes);
        }
        s->str[s->len - 1] = '\0';
        srd_dbg("%s", s->str);