diff options
author | Peter Wu <peter@lekensteyn.nl> | 2017-01-10 23:46:31 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2017-01-13 22:26:37 +0000 |
commit | 298085def885f4dc1a8edc1dff15fa6c8ba081d5 (patch) | |
tree | 148779982a76cfe38a47f2181a1a79031e675b08 | |
parent | dc647f115e69bc578bc6e40a6111e7f0aebeb7b1 (diff) | |
download | wireshark-298085def885f4dc1a8edc1dff15fa6c8ba081d5.tar.gz wireshark-298085def885f4dc1a8edc1dff15fa6c8ba081d5.tar.bz2 wireshark-298085def885f4dc1a8edc1dff15fa6c8ba081d5.zip |
Qt: fix memory leaks in UatDialog
Avoid leaking memory for the stringified UAT field values (tostr) and
for copies of rows.
Change-Id: I1bf20035fabe92da8216c820bc47ebce7dd73951
Reviewed-on: https://code.wireshark.org/review/19604
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r-- | ui/qt/uat_model.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/qt/uat_model.cpp b/ui/qt/uat_model.cpp index 03337e2c51..29f358a18f 100644 --- a/ui/qt/uat_model.cpp +++ b/ui/qt/uat_model.cpp @@ -67,11 +67,14 @@ QVariant UatModel::data(const QModelIndex &index, int role) const if (field->mode == PT_TXTMOD_HEXBYTES) { char* temp_str = bytes_to_str(NULL, (const guint8 *) str, length); + g_free(str); QString qstr(temp_str); wmem_free(NULL, temp_str); return qstr; } else { - return QString::fromUtf8(str); + QString qstr(str); + g_free(str); + return qstr; } } @@ -248,6 +251,11 @@ bool UatModel::copyRow(int dst_row, int src_row) const void *src_record = UAT_INDEX_PTR(uat_, src_row); void *dst_record = UAT_INDEX_PTR(uat_, dst_row); + // insertRows always initializes the record with empty value. Before copying + // over the new values, be sure to clear the old fields. + if (uat_->free_cb) { + uat_->free_cb(dst_record); + } if (uat_->copy_cb) { uat_->copy_cb(dst_record, src_record, uat_->record_size); } else { |