diff options
author | John Thacker <johnthacker@gmail.com> | 2023-03-01 21:06:11 -0500 |
---|---|---|
committer | John Thacker <johnthacker@gmail.com> | 2023-03-01 21:10:42 -0500 |
commit | 0d23b6692f6a54cc07573abb451a919febbc1b3e (patch) | |
tree | 38d6938d2425fb403b4f4aef6613f06029036878 /ui | |
parent | 44a38f0ad4451b66ea35c1c56d93b1888ffb6f0d (diff) |
Qt: RtpStreamDialog leak
In tapReset, the select rtpstread_id is copied member by member
by QList append(), so don't allocate pointers on the heap that
will be leaked. (Coverity 1477952)
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/rtp_stream_dialog.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ui/qt/rtp_stream_dialog.cpp b/ui/qt/rtp_stream_dialog.cpp index effde6f07c..7153e0aee6 100644 --- a/ui/qt/rtp_stream_dialog.cpp +++ b/ui/qt/rtp_stream_dialog.cpp @@ -498,13 +498,16 @@ void RtpStreamDialog::tapReset(rtpstream_tapinfo_t *tapinfo) rtp_stream_dialog->freeLastSelected(); /* Copy currently selected rtpstream_ids */ QTreeWidgetItemIterator iter(rtp_stream_dialog->ui->streamTreeWidget); + rtpstream_id_t selected_id; while (*iter) { RtpStreamTreeWidgetItem *rsti = static_cast<RtpStreamTreeWidgetItem*>(*iter); rtpstream_info_t *stream_info = rsti->streamInfo(); if ((*iter)->isSelected()) { - rtpstream_id_t *i = (rtpstream_id_t *)g_malloc0(sizeof(rtpstream_id_t)); - rtpstream_id_copy(&stream_info->id, i); - rtp_stream_dialog->last_selected_.append(*i); + /* QList.append() does a member by member copy, so allocate new + * addresses. rtpstream_id_copy() overwrites all struct members. + */ + rtpstream_id_copy(&stream_info->id, &selected_id); + rtp_stream_dialog->last_selected_.append(selected_id); } ++iter; } |