]> sigrok.org Git - pulseview.git/commitdiff
Fix memory leak in DecoderMenu
authorJon Burgess <redacted>
Sun, 14 Oct 2018 22:52:24 +0000 (23:52 +0100)
committerUwe Hermann <redacted>
Tue, 16 Oct 2018 21:37:19 +0000 (23:37 +0200)
==214004== 1,536 (16 direct, 1,520 indirect) bytes in 1 blocks are definitely lost in loss record 6,288 of 6,442
==214004==    at 0x4C2EE0B: malloc (vg_replace_malloc.c:299)
==214004==    by 0x67D8435: g_malloc (in /usr/lib64/libglib-2.0.so.0.5600.3)
==214004==    by 0x67F0056: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.5600.3)
==214004==    by 0x67F14FA: g_slist_copy_deep (in /usr/lib64/libglib-2.0.so.0.5600.3)
==214004==    by 0x5584FC: pv::widgets::DecoderMenu::DecoderMenu(QWidget*, bool) (decodermenu.cpp:33)
==214004==

pv/widgets/decodermenu.cpp

index 5e54589372c98373b79fef15db8a7b47ce339016..28b54babdfb9aad3c0e67e2a732b22ac79cbe918 100644 (file)
@@ -30,9 +30,9 @@ DecoderMenu::DecoderMenu(QWidget *parent, bool first_level_decoder) :
        QMenu(parent),
        mapper_(this)
 {
-       GSList *l = g_slist_sort(g_slist_copy(
+       GSList *li = g_slist_sort(g_slist_copy(
                (GSList*)srd_decoder_list()), decoder_name_cmp);
-       for (; l; l = l->next) {
+       for (GSList *l = li; l; l = l->next) {
                const srd_decoder *const d = (srd_decoder*)l->data;
                assert(d);
 
@@ -46,7 +46,7 @@ DecoderMenu::DecoderMenu(QWidget *parent, bool first_level_decoder) :
                                &mapper_, SLOT(map()));
                }
        }
-       g_slist_free(l);
+       g_slist_free(li);
 
        connect(&mapper_, SIGNAL(mapped(QObject*)),
                this, SLOT(on_action(QObject*)));