[vlc-commits] [Git][videolan/vlc][master] qt: fix a couple of leaks in expert prefs

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Thu Mar 10 08:38:58 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
bccef1d5 by Lyndon Brown at 2022-03-10T07:36:08+00:00
qt: fix a couple of leaks in expert prefs

Identified by a different invocation of ASAN than I'd previously used..

wrt. the second fix it seems `clear()` alone does not destroy these items..

```
Direct leak of 64560 byte(s) in 1345 object(s) allocated from:
    #0 0x7f1f87268f37 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x7f1f71099981 in ExpertPrefsTableModel::ExpertPrefsTableModel(module_t**, unsigned long, QWidget*) ../../modules/gui/qt/dialogs/preferences/expert_model.cpp:260
    #2 0x7f1f710a32fa in PrefsDialog::setExpert() ../../modules/gui/qt/dialogs/preferences/preferences.cpp:106
    #3 0x7f1f710a8851 in PrefsDialog::PrefsDialog(QWindow*, qt_intf_t*) ../../modules/gui/qt/dialogs/preferences/preferences.cpp:74
    #4 0x7f1f70ee43e2 in DialogsProvider::prefsDialog() ../../modules/gui/qt/dialogs/dialogs_provider.cpp:253
    #5 0x7f1f714f6f97 in DialogsProvider::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) gui/qt/dialogs/dialogs_provider.moc.cpp:268
    #6 0x7f1f714f7c11 in DialogsProvider::qt_metacall(QMetaObject::Call, int, void**) gui/qt/dialogs/dialogs_provider.moc.cpp:388
    #7 0x7f1f70568f1c  (/lib/x86_64-linux-gnu/libQt5Qml.so.5+0x2c4f1c)

...

Direct leak of 1112 byte(s) in 122 object(s) allocated from:
    #0 0x7f1f872127a7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f1f710950f0 in ExpertPrefsTableItem::ExpertPrefsTableItem(module_config_t*, QString const&, QString const&, bool) ../../modules/gui/qt/dialogs/preferences/expert_model.cpp:61
    #2 0x7f1f710999ac in ExpertPrefsTableModel::ExpertPrefsTableModel(module_t**, unsigned long, QWidget*) ../../modules/gui/qt/dialogs/preferences/expert_model.cpp:260
    #3 0x7f1f710a32fa in PrefsDialog::setExpert() ../../modules/gui/qt/dialogs/preferences/preferences.cpp:106
    #4 0x7f1f710a8851 in PrefsDialog::PrefsDialog(QWindow*, qt_intf_t*) ../../modules/gui/qt/dialogs/preferences/preferences.cpp:74
    #5 0x7f1f70ee43e2 in DialogsProvider::prefsDialog() ../../modules/gui/qt/dialogs/dialogs_provider.cpp:253
    #6 0x7f1f714f6f97 in DialogsProvider::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) gui/qt/dialogs/dialogs_provider.moc.cpp:268
    #7 0x7f1f714f7c11 in DialogsProvider::qt_metacall(QMetaObject::Call, int, void**) gui/qt/dialogs/dialogs_provider.moc.cpp:388
    #8 0x7f1f70568f1c  (/lib/x86_64-linux-gnu/libQt5Qml.so.5+0x2c4f1c)

...

Direct leak of 33 byte(s) in 33 object(s) allocated from:
    #0 0x7f1f872677cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7f1f86eac342 in vlc_alloc ../../include/vlc_common.h:1149
    #2 0x7f1f86eac342 in module_config_get ../../src/modules/modules.c:346
    #3 0x7f1f710995f5 in ExpertPrefsTableModel::ExpertPrefsTableModel(module_t**, unsigned long, QWidget*) ../../modules/gui/qt/dialogs/preferences/expert_model.cpp:230
    #4 0x7f1f710a32fa in PrefsDialog::setExpert() ../../modules/gui/qt/dialogs/preferences/preferences.cpp:106
    #5 0x7f1f710a8851 in PrefsDialog::PrefsDialog(QWindow*, qt_intf_t*) ../../modules/gui/qt/dialogs/preferences/preferences.cpp:74
    #6 0x7f1f70ee43e2 in DialogsProvider::prefsDialog() ../../modules/gui/qt/dialogs/dialogs_provider.cpp:253
    #7 0x7f1f714f6f97 in DialogsProvider::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) gui/qt/dialogs/dialogs_provider.moc.cpp:268
    #8 0x7f1f714f7c11 in DialogsProvider::qt_metacall(QMetaObject::Call, int, void**) gui/qt/dialogs/dialogs_provider.moc.cpp:388
    #9 0x7f1f70568f1c  (/lib/x86_64-linux-gnu/libQt5Qml.so.5+0x2c4f1c)
```

- - - - -


1 changed file:

- modules/gui/qt/dialogs/preferences/expert_model.cpp


Changes:

=====================================
modules/gui/qt/dialogs/preferences/expert_model.cpp
=====================================
@@ -229,7 +229,11 @@ ExpertPrefsTableModel::ExpertPrefsTableModel( module_t **mod_list, size_t mod_co
         unsigned confsize;
         module_config_t *const config = module_config_get( mod, &confsize );
         if( confsize == 0 )
+        {
+            /* If has items but none are visible, we still need to deallocate */
+            module_config_free( config );
             continue;
+        }
         config_sets.append( config );
 
         bool is_core = module_is_main( mod );
@@ -281,7 +285,10 @@ ExpertPrefsTableModel::ExpertPrefsTableModel( module_t **mod_list, size_t mod_co
 
 ExpertPrefsTableModel::~ExpertPrefsTableModel()
 {
-    items.clear(); /* We must destroy the items before releasing the config set */
+    /* We must destroy the items before releasing the config set */
+    foreach ( ExpertPrefsTableItem *item, items )
+        delete item;
+    items.clear();
     foreach ( module_config_t *config_set, config_sets )
         module_config_free( config_set );
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/bccef1d574824910ab2e0f0d997e66320a3f63a5

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/bccef1d574824910ab2e0f0d997e66320a3f63a5
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list