qt: fix use-after-free pattern
authorPeter Wu <peter@lekensteyn.nl>
Sat, 29 Nov 2014 18:29:26 +0000 (19:29 +0100)
committerGerald Combs <gerald@wireshark.org>
Mon, 1 Dec 2014 00:56:26 +0000 (00:56 +0000)
commit18f01099694ed5c2758105f893ba37589f552717
tree78464c882944cf12058ed99ac9829ab03c69cde8
parent846bb5394812c39359dfdbbf7e8755a7e3cf5326
qt: fix use-after-free pattern

qstring.toUtf8() returns a QByteArray object and .constData() returns
a pointer inside that object. It is not safe to store this pointer as
it will become invalid after the statement. Store a const reference
instead. (Due to scoping differences, some are copy-assigned though.)

In the UAT dialog, strlen(bytes.constData()) has also been replaced by
bytes.size() as an optimization.

Caught by ASAN.

Change-Id: Ie09f999a32d0ef1abaa1e658b9403b74bedffc37
Reviewed-on: https://code.wireshark.org/review/5528
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
ui/qt/capture_filter_combo.cpp
ui/qt/conversation_dialog.cpp
ui/qt/display_filter_combo.cpp
ui/qt/endpoint_dialog.cpp
ui/qt/export_pdu_dialog.cpp
ui/qt/traffic_table_dialog.cpp
ui/qt/uat_dialog.cpp