From 2b2eea1793dbff813896e1ae9dff1bedb39ee010 Mon Sep 17 00:00:00 2001
From: Jeff Morriss <jeff.morriss.ws@gmail.com>
Date: Wed, 2 Jan 2019 16:45:05 -0500
Subject: [PATCH] 6lowpan: don't try to use (new) TVB that wasn't created.

If the IPHC TVB wasn't created then bail out of dissection before trying
to use it.

Bug: 15217
Change-Id: I6e297590cdf86e13b0185f75f1d409888f2498d8
Reviewed-on: https://code.wireshark.org/review/31308
Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
(cherry picked from commit 62e81562e4e3a33dad705b1b66a3407afbde3242)
Reviewed-on: https://code.wireshark.org/review/31311
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
---
 epan/dissectors/packet-6lowpan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/epan/dissectors/packet-6lowpan.c b/epan/dissectors/packet-6lowpan.c
index 6ac3a63..7daa8e8 100644
--- a/epan/dissectors/packet-6lowpan.c
+++ b/epan/dissectors/packet-6lowpan.c
@@ -1218,6 +1218,7 @@ dissect_6lowpan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
         next = dissect_6lowpan_6loRH(next, offset, lowpan_tree);
         if (tvb_get_bits8(next, 0, LOWPAN_PATTERN_IPHC_BITS) == LOWPAN_PATTERN_IPHC) {
             next = dissect_6lowpan_iphc(next, pinfo, lowpan_tree, -1, src_iid, dst_iid);
+            if (!next) return tvb_captured_length(tvb);
         }
         if (tvb_get_bits8(next, 0, LOWPAN_PATTERN_HC1_BITS) == LOWPAN_PATTERN_HC1) {
             next = dissect_6lowpan_hc1(next, pinfo, lowpan_tree, -1, src_iid, dst_iid);
@@ -1816,7 +1817,7 @@ dissect_6lowpan_hc1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint dg
  *      siid            ; Source Interface ID.
  *      diid            ; Destination Interface ID.
  *  RETURNS
- *      tvbuff_t *      ; The remaining payload to be parsed.
+ *      tvbuff_t *      ; The remaining payload to be parsed or NULL on error.
  *---------------------------------------------------------------
  */
 static tvbuff_t *
-- 
2.7.4
