aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2018-01-31 09:31:47 -0800
committerMichael Mann <mmann78@netscape.net>2018-02-01 02:05:06 +0000
commit0c7bbc75364ce21e6e911c93da748abf854999b1 (patch)
tree660e2929e9b2c9b1d99598cc1493df7efb1cef9a
parentb14e32cc77ded4a4db6f9cc6e207ce39f55637e9 (diff)
Qt: Avoid a potentially large memdup.
Use QByteArray::fromRawData + tvb_get_ptr to create our ByteViewText data instead of tvb_memdup. If our tvb lifetime is shorter than our ByteViewText lifetime then that's a bug. Change-Id: Iede275578a1493b8658308e0778f7f0799d6c6cd Reviewed-on: https://code.wireshark.org/review/25534 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--ui/qt/byte_view_tab.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/ui/qt/byte_view_tab.cpp b/ui/qt/byte_view_tab.cpp
index 36a21c0d1f..2974a215ed 100644
--- a/ui/qt/byte_view_tab.cpp
+++ b/ui/qt/byte_view_tab.cpp
@@ -94,8 +94,10 @@ void ByteViewTab::addTab(const char *name, tvbuff_t *tvb) {
encoding = (packet_char_enc)cap_file_->current_frame->flags.encoding;
QByteArray data;
- if ( tvb )
- data = QByteArray((const char *) tvb_memdup(wmem_file_scope(), tvb, 0, -1), tvb_captured_length(tvb));
+ if ( tvb ) {
+ int data_len = (int) tvb_captured_length(tvb);
+ data = QByteArray::fromRawData((const char *) tvb_get_ptr(tvb, 0, data_len), data_len);
+ }
ByteViewText * byte_view_text = new ByteViewText(data, encoding, this);
byte_view_text->setAccessibleName(name);