Wireshark-commits: [Wireshark-commits] master 18f0109: qt: fix use-after-free pattern

From: Wireshark code review <code-review-do-not-reply@xxxxxxxxxxxxx>
Date: Mon, 1 Dec 2014 00:56:29 +0000 (UTC)
URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=18f01099694ed5c2758105f893ba37589f552717
Submitter: Gerald Combs (gerald@xxxxxxxxxxxxx)
Changed: branch: master
Repository: wireshark

Commits:

18f0109 by Peter Wu (peter@xxxxxxxxxxxxx):

    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@xxxxxxxxxxxxx>
    Tested-by: Petri Dish Buildbot <buildbot-no-reply@xxxxxxxxxxxxx>
    Reviewed-by: Gerald Combs <gerald@xxxxxxxxxxxxx>
    

Actions performed:

    from  846bb53   Add a Buffer to wtap_pkthdr to hold file-type-specific packet metadata.
    adds  18f0109   qt: fix use-after-free pattern


Summary of changes:
 ui/qt/capture_filter_combo.cpp |    7 +++----
 ui/qt/conversation_dialog.cpp  |    8 ++++++--
 ui/qt/display_filter_combo.cpp |    7 +++----
 ui/qt/endpoint_dialog.cpp      |    4 +++-
 ui/qt/export_pdu_dialog.cpp    |    8 +++-----
 ui/qt/traffic_table_dialog.cpp |    4 +++-
 ui/qt/uat_dialog.cpp           |   17 +++++++++--------
 7 files changed, 30 insertions(+), 25 deletions(-)