From 6cc90dde536beb28671a4537f93f85d67a66a0ff Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 21 Jun 2016 11:21:33 -0700 Subject: As with dissector_add_uint(), so with dissector_add_{string,guid}. Improve the error message for a null disssector handle. Fix indentation while we're at it. Change-Id: I1cb2f8ac52e56fc98f6b3ad981018f571e5a7bf0 Reviewed-on: https://code.wireshark.org/review/16060 Reviewed-by: Guy Harris --- epan/packet.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/epan/packet.c b/epan/packet.c index 95d6665e16..3573a982df 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -1303,8 +1303,15 @@ dissector_add_string(const char *name, const gchar *pattern, char *key; /* - * Make sure the dissector table exists. + * Make sure the handle and the dissector table exist. */ + if (handle == NULL) { + fprintf(stderr, "OOPS: handle to register \"%s\" to doesn't exist\n", + name); + if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL) + abort(); + return; + } if (sub_dissectors == NULL) { fprintf(stderr, "OOPS: dissector table \"%s\" doesn't exist\n", name); @@ -1315,8 +1322,6 @@ dissector_add_string(const char *name, const gchar *pattern, return; } - /* sanity checks */ - g_assert(handle!=NULL); switch (sub_dissectors->type) { case FT_STRING: @@ -1600,8 +1605,15 @@ void dissector_add_guid(const char *name, guid_key* guid_val, dissector_handle_t sub_dissectors = find_dissector_table(name); /* - * Make sure the dissector table exists. + * Make sure the handle and the dissector table exist. */ + if (handle == NULL) { + fprintf(stderr, "OOPS: handle to register \"%s\" to doesn't exist\n", + name); + if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL) + abort(); + return; + } if (sub_dissectors == NULL) { fprintf(stderr, "OOPS: dissector table \"%s\" doesn't exist\n", name); @@ -1612,9 +1624,7 @@ void dissector_add_guid(const char *name, guid_key* guid_val, dissector_handle_t return; } - /* sanity checks */ - g_assert(handle!=NULL); - if (sub_dissectors->type != FT_GUID) { + if (sub_dissectors->type != FT_GUID) { g_assert_not_reached(); } -- cgit v1.2.3