diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2018-09-01 13:15:12 +0200 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2018-09-02 18:21:32 +0000 |
commit | cb002c597a4e4635b1743cb178301dc46b7d01de (patch) | |
tree | d6df6e6303f2214a5593c7be85edde0bd7b66da6 /ui/qt | |
parent | 3ce847e39e4b5a51f4163459e6206b62049f8930 (diff) |
Qt: Avoid crash for ByteViewTab with 0 bytes
A ByteViewTab with 0 bytes is not useful, but may happen.
The crash could be reproduced with the following Lua code:
local t = ByteArray.new():tvb()
Change-Id: I256fd7fc2b91aa3c1161c46558c647308a3d564b
Reviewed-on: https://code.wireshark.org/review/29383
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/byte_view_tab.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ui/qt/byte_view_tab.cpp b/ui/qt/byte_view_tab.cpp index 7081576630..eff04661fa 100644 --- a/ui/qt/byte_view_tab.cpp +++ b/ui/qt/byte_view_tab.cpp @@ -95,7 +95,9 @@ void ByteViewTab::addTab(const char *name, tvbuff_t *tvb) { QByteArray data; if ( tvb ) { int data_len = (int) tvb_captured_length(tvb); - data = QByteArray::fromRawData((const char *) tvb_get_ptr(tvb, 0, data_len), data_len); + if (data_len > 0) { + data = QByteArray::fromRawData((const char *) tvb_get_ptr(tvb, 0, data_len), data_len); + } } ByteViewText * byte_view_text = new ByteViewText(data, encoding, this); |