summaryrefslogtreecommitdiff
path: root/ui/qt/manage_interfaces_dialog.cpp
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2017-06-26 23:40:22 +0200
committerRoland Knall <rknall@gmail.com>2017-06-27 21:16:10 +0000
commit6bc0ba845100acb3c721e4f945bafeb1bed6c942 (patch)
treeb494ef606a66643fce9be1d46c075ec57449326b /ui/qt/manage_interfaces_dialog.cpp
parent381fd410cbea10207d15ee9bd05eaa18f91c60ac (diff)
downloadwireshark-6bc0ba845100acb3c721e4f945bafeb1bed6c942.tar.gz
Qt: fix alloc-dealloc-mismatch while adding named pipe
ManageInterfacesDialog::on_addPipe_clicked uses g_new0 to create an "interface_t" instance, but InterfaceTreeCacheModel uses qDeleteAll which results in ASAN reporting "alloc-dealloc-mismatch (malloc vs operator delete)". To fix this, remove the dynamic allocation and make InterfaceTreeCacheModel store the instance internally. Change-Id: I9426dfc88d0a54a889bbbc9cf336c0a6af76920e Reviewed-on: https://code.wireshark.org/review/22410 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/qt/manage_interfaces_dialog.cpp')
-rw-r--r--ui/qt/manage_interfaces_dialog.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/ui/qt/manage_interfaces_dialog.cpp b/ui/qt/manage_interfaces_dialog.cpp
index 23986a974e..19b0d312d9 100644
--- a/ui/qt/manage_interfaces_dialog.cpp
+++ b/ui/qt/manage_interfaces_dialog.cpp
@@ -222,24 +222,25 @@ void ManageInterfacesDialog::on_buttonBox_accepted()
void ManageInterfacesDialog::on_addPipe_clicked()
{
- interface_t * device = g_new0(interface_t, 1);
-
- device->name = qstring_strdup(tr("New Pipe"));
- device->display_name = g_strdup(device->name);
- device->hidden = FALSE;
- device->selected = TRUE;
- device->pmode = global_capture_opts.default_options.promisc_mode;
- device->has_snaplen = global_capture_opts.default_options.has_snaplen;
- device->snaplen = global_capture_opts.default_options.snaplen;
- device->cfilter = g_strdup(global_capture_opts.default_options.cfilter);
+ interface_t device;
+
+ memset(&device, 0, sizeof(device));
+ device.name = qstring_strdup(tr("New Pipe"));
+ device.display_name = g_strdup(device.name);
+ device.hidden = FALSE;
+ device.selected = TRUE;
+ device.pmode = global_capture_opts.default_options.promisc_mode;
+ device.has_snaplen = global_capture_opts.default_options.has_snaplen;
+ device.snaplen = global_capture_opts.default_options.snaplen;
+ device.cfilter = g_strdup(global_capture_opts.default_options.cfilter);
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- device->buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
+ device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
#endif
- device->active_dlt = -1;
- device->if_info.name = g_strdup(device->name);
- device->if_info.type = IF_PIPE;
+ device.active_dlt = -1;
+ device.if_info.name = g_strdup(device.name);
+ device.if_info.type = IF_PIPE;
- sourceModel->addDevice(device);
+ sourceModel->addDevice(&device);
updateWidgets();
}