Qt: fix leak in DecodeAsModel.

The list of items was free'd, but not the items within it. Delete
them explicitly and do it in the class destructor.

Fix: #17127.
This commit is contained in:
Dario Lombardo 2021-01-03 15:44:49 +01:00 committed by Wireshark GitLab Utility
parent 0f7ec0694e
commit 602a1ef613
2 changed files with 10 additions and 0 deletions

View File

@ -50,6 +50,13 @@ DecodeAsModel::DecodeAsModel(QObject *parent, capture_file *cf) :
{
}
DecodeAsModel::~DecodeAsModel()
{
foreach(DecodeAsItem* item, decode_as_items_)
delete item;
decode_as_items_.clear();
}
Qt::ItemFlags DecodeAsModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
@ -400,6 +407,8 @@ void DecodeAsModel::clearAll()
return;
beginResetModel();
foreach(DecodeAsItem* item, decode_as_items_)
delete item;
decode_as_items_.clear();
endResetModel();
}

View File

@ -48,6 +48,7 @@ class DecodeAsModel : public QAbstractTableModel
public:
DecodeAsModel(QObject *parent, capture_file *cf = NULL);
virtual ~DecodeAsModel();
enum DecodeAsColumn {
colTable = 0, // aka "Field" (or dissector table like "TCP Port")