Qt: do not crash when selecting a field without tvb
authorPeter Wu <peter@lekensteyn.nl>
Sun, 12 Nov 2017 04:00:56 +0000 (04:00 +0000)
committerRoland Knall <rknall@gmail.com>
Sun, 12 Nov 2017 09:43:37 +0000 (09:43 +0000)
If no tvb is attached to a field, crashing is not the expected result.

Change-Id: Ica0e95326cfcfeb015016770d1b930a9f0447066
Fixes: v2.5.0rc0-1627-g8a6ea0e454 ("Qt: Further cleanup ByteView")
Ping-Bug: 14205
Reviewed-on: https://code.wireshark.org/review/24370
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
ui/qt/utils/field_information.cpp

index 77997eab8409e55bfdee2961c911dcfd964791e2..fc58222101c48c2c30b64220fa2239e53ee0d0ad 100644 (file)
@@ -88,7 +88,7 @@ bool FieldInformation::tvbContains(FieldInformation *child)
 FieldInformation::Position FieldInformation::position() const
 {
     Position pos = {-1, -1, -1};
-    if ( fi_ )
+    if ( fi_ && fi_->ds_tvb )
     {
         guint len = tvb_captured_length(fi_->ds_tvb);
 
@@ -118,7 +118,7 @@ FieldInformation::Position FieldInformation::position() const
 FieldInformation::Position FieldInformation::appendix() const
 {
     Position pos = {-1, -1, -1};
-    if ( fi_ )
+    if ( fi_ && fi_->ds_tvb )
     {
         guint len = tvb_captured_length(fi_->ds_tvb);