From 5162769712f3b69895f26154e64a0ebefd08704b Mon Sep 17 00:00:00 2001 From: canpadawan Date: Fri, 8 Jul 2016 11:01:53 +0200 Subject: [PATCH] bug fix: use after free --- canframemodel.cpp | 9 +++++++++ canframemodel.h | 1 + mainwindow.cpp | 7 +++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index e1cb200..799ae10 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -3,6 +3,15 @@ #include #include "utility.h" + +CANFrameModel::~CANFrameModel() +{ + frames.clear(); + filteredFrames.clear(); + filters.clear(); +} + + int CANFrameModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); diff --git a/canframemodel.h b/canframemodel.h index 57e6e6a..f69858a 100644 --- a/canframemodel.h +++ b/canframemodel.h @@ -16,6 +16,7 @@ class CANFrameModel: public QAbstractTableModel public: CANFrameModel(QObject *parent = 0); + virtual ~CANFrameModel(); int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role) const; diff --git a/mainwindow.cpp b/mainwindow.cpp index d5826c0..27546b4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -273,12 +273,11 @@ MainWindow::~MainWindow() snifferWindow = NULL; } - delete elapsedTime; - delete ui; - delete dbcHandler; - model->clearFrames(); delete model; + delete elapsedTime; + delete dbcHandler; + delete ui; } void MainWindow::exitApp()