As with dissector_add_uint(), so with dissector_add_{string,guid}.
authorGuy Harris <guy@alum.mit.edu>
Tue, 21 Jun 2016 18:21:33 +0000 (11:21 -0700)
committerGuy Harris <guy@alum.mit.edu>
Tue, 21 Jun 2016 18:21:42 +0000 (18:21 +0000)
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 <guy@alum.mit.edu>
epan/packet.c

index 95d6665e168f160cf05be0f505a25cc75b9b2431..3573a982dfe55648926fc77a08dfb960226aed0f 100644 (file)
@@ -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();
        }