From: Jon Burgess Date: Sun, 14 Oct 2018 17:55:47 +0000 (+0100) Subject: Fix memory leak in print_searchpaths() X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=commitdiff_plain;h=07560450ad9427b01b99f4b3b10483e7fdf3926f Fix memory leak in print_searchpaths() ==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) --- diff --git a/srd.c b/srd.c index 248d8e5..22f47fc 100644 --- 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);