diff options
author | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-08-01 17:19:20 +0000 |
---|---|---|
committer | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-08-01 17:19:20 +0000 |
commit | d0cb52d0b7c0db40867db74fec9f292fb8ac9142 (patch) | |
tree | 364f974e280dd22937a0b2ade949eee357e154c5 | |
parent | 10e40c163873816cf4afa8fd3ac10975498f21eb (diff) |
Move some asserts to be triggered sooner.
svn path=/trunk/; revision=51082
-rw-r--r-- | epan/packet.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/epan/packet.c b/epan/packet.c index 9af46e1de3..7680038b58 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -74,8 +74,13 @@ void packet_init(void) { frame_handle = find_dissector("frame"); + g_assert(frame_handle != NULL); + data_handle = find_dissector("data"); + g_assert(data_handle != NULL); + proto_malformed = proto_get_id_by_filter_name("malformed"); + g_assert(proto_malformed != -1); } void @@ -366,20 +371,15 @@ dissect_packet(epan_dissect_t *edt, struct wtap_pkthdr *phdr, * sub-dissector can throw, dissect_frame() itself may throw * a ReportedBoundsError in bizarre cases. Thus, we catch the exception * in this function. */ - if(frame_handle != NULL) - call_dissector(frame_handle, edt->tvb, &edt->pi, edt->tree); + call_dissector(frame_handle, edt->tvb, &edt->pi, edt->tree); } CATCH(BoundsError) { g_assert_not_reached(); } CATCH2(FragmentBoundsError, ReportedBoundsError) { - if(proto_malformed != -1){ - proto_tree_add_protocol_format(edt->tree, proto_malformed, edt->tvb, 0, 0, - "[Malformed Frame: Packet Length]" ); - } else { - g_assert_not_reached(); - } + proto_tree_add_protocol_format(edt->tree, proto_malformed, edt->tvb, 0, 0, + "[Malformed Frame: Packet Length]" ); } ENDTRY; @@ -2067,7 +2067,6 @@ call_dissector_with_data(dissector_handle_t handle, tvbuff_t *tvb, * The protocol was disabled, or the dissector rejected * it. Just dissect this packet as data. */ - g_assert(data_handle != NULL); g_assert(data_handle->protocol != NULL); call_dissector_work(data_handle, tvb, pinfo, tree, TRUE, NULL); return tvb_length(tvb); |