summaryrefslogtreecommitdiff
path: root/ui/qt
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2017-01-10 23:46:31 +0100
committerPeter Wu <peter@lekensteyn.nl>2017-01-13 22:26:37 +0000
commit298085def885f4dc1a8edc1dff15fa6c8ba081d5 (patch)
tree148779982a76cfe38a47f2181a1a79031e675b08 /ui/qt
parentdc647f115e69bc578bc6e40a6111e7f0aebeb7b1 (diff)
downloadwireshark-298085def885f4dc1a8edc1dff15fa6c8ba081d5.tar.gz
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>
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/uat_model.cpp10
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 {