fixed memory leak in `cppcheck-gui` (#4248)

* settingsdialog.cpp: fixed memory leak

Direct leak of 200 byte(s) in 1 object(s) allocated from:
    #0 0xa15a2d in operator new(unsigned long) (/mnt/s/GitHub/cppcheck-fw/cmake-build-debug-wsl-kali-clang-asan-ubsan/bin/cppcheck-gui+0xa15a2d)
    #1 0xe639af in SettingsDialog::SettingsDialog(ApplicationList*, TranslationHandler*, QWidget*) /mnt/s/GitHub/cppcheck-fw/gui/settingsdialog.cpp:75:21
    #2 0xc67807 in MainWindow::programSettings() /mnt/s/GitHub/cppcheck-fw/gui/mainwindow.cpp:1064:20
    #3 0xd1deb8 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (MainWindow::*)()>::call(void (MainWindow::*)(), MainWindow*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:152:13
    #4 0xd1db5c in void QtPrivate::FunctionPointer<void (MainWindow::*)()>::call<QtPrivate::List<>, void>(void (MainWindow::*)(), MainWindow*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:185:13
    #5 0xd1d675 in QtPrivate::QSlotObject<void (MainWindow::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:418:17
    #6 0x7f9687f26132  (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2e6132)
    #7 0x7f96889ccdc1 in QAction::triggered(bool) (/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x15cdc1)

* resultstree.cpp: adjusted TODO about memory leaks
This commit is contained in:
Oliver Stöneberg 2022-07-09 22:32:48 +02:00 committed by GitHub
parent 8215521843
commit c4fc1bf1c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -316,7 +316,19 @@ QStandardItem *ResultsTree::addBacktraceFiles(QStandardItem *parent,
list[0]->setIcon(QIcon(icon));
}
//TODO Does this leak memory? Should items from list be deleted?
/* TODO: the list items leak memory
Indirect leak of 80624 byte(s) in 5039 object(s) allocated from:
#0 0xa15a2d in operator new(unsigned long) (/mnt/s/GitHub/cppcheck-fw/cmake-build-debug-wsl-kali-clang-asan-ubsan/bin/cppcheck-gui+0xa15a2d)
#1 0xdda276 in ResultsTree::createNormalItem(QString const&) /mnt/s/GitHub/cppcheck-fw/gui/resultstree.cpp:122:27
#2 0xde4290 in ResultsTree::addBacktraceFiles(QStandardItem*, ErrorLine const&, bool, QString const&, bool) /mnt/s/GitHub/cppcheck-fw/gui/resultstree.cpp:289:13
#3 0xddd754 in ResultsTree::addErrorItem(ErrorItem const&) /mnt/s/GitHub/cppcheck-fw/gui/resultstree.cpp:199:30
#4 0xe37046 in ResultsView::error(ErrorItem const&) /mnt/s/GitHub/cppcheck-fw/gui/resultsview.cpp:129:21
#5 0xd2448d in QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<ErrorItem const&>, void, void (ResultsView::*)(ErrorItem const&)>::call(void (ResultsView::*)(ErrorItem const&), ResultsView*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:152:13
#6 0xd2402c in void QtPrivate::FunctionPointer<void (ResultsView::*)(ErrorItem const&)>::call<QtPrivate::List<ErrorItem const&>, void>(void (ResultsView::*)(ErrorItem const&), ResultsView*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:185:13
#7 0xd23b45 in QtPrivate::QSlotObject<void (ResultsView::*)(ErrorItem const&), QtPrivate::List<ErrorItem const&>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:418:17
#8 0x7fd2536cc0dd in QObject::event(QEvent*) (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2dc0dd)
#9 0x7fd2541836be in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1636be)
*/
return list[0];
}

View File

@ -115,6 +115,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
SettingsDialog::~SettingsDialog()
{
saveSettings();
delete mCurrentStyle;
delete mUI;
}