From c6a0e2a7916a689dfb642b004d07f6fc76fd04f3 Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Thu, 5 Oct 2017 21:39:10 +0200 Subject: packet.c: fix a control flow issue reported by Coverity (CID 1418671) Let's perform the check before potentially breaking the loop. While we are at it, let's update the test to remove the last layer so as to match the one used to add it. Change-Id: I5807219de75c4e2c23b9435d6271ad60aec45783 Reviewed-on: https://code.wireshark.org/review/23844 Petri-Dish: Pascal Quantin Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/packet.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/epan/packet.c b/epan/packet.c index 00c6609f0f..37579fd294 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -767,7 +767,7 @@ call_dissector_work(dissector_handle_t handle, tvbuff_t *tvb, packet_info *pinfo */ len = call_dissector_through_handle(handle, tvb, pinfo, tree, data); } - if (add_proto_name && + if (handle->protocol != NULL && !proto_is_pino(handle->protocol) && add_proto_name && (len == 0 || (tree && saved_tree_count == tree->tree_data->count))) { /* * We've added a layer and either the dissector didn't @@ -2674,11 +2674,6 @@ dissector_try_heuristic(heur_dissector_list_t sub_dissectors, tvbuff_t *tvb, pinfo->heur_list_name = hdtbl_entry->list_name; len = (hdtbl_entry->dissector)(tvb, pinfo, tree, data); - if (len) { - *heur_dtbl_entry = hdtbl_entry; - status = TRUE; - break; - } if (hdtbl_entry->protocol != NULL && (len == 0 || (tree && saved_tree_count == tree->tree_data->count))) { /* @@ -2691,6 +2686,11 @@ dissector_try_heuristic(heur_dissector_list_t sub_dissectors, tvbuff_t *tvb, wmem_list_remove_frame(pinfo->layers, wmem_list_tail(pinfo->layers)); } } + if (len) { + *heur_dtbl_entry = hdtbl_entry; + status = TRUE; + break; + } } pinfo->current_proto = saved_curr_proto; -- cgit v1.2.3