Don't try to look in a non-existent hash table.
authorGuy Harris <guy@alum.mit.edu>
Tue, 9 Dec 2014 01:30:04 +0000 (17:30 -0800)
committerGuy Harris <guy@alum.mit.edu>
Tue, 9 Dec 2014 01:30:41 +0000 (01:30 +0000)
We only create hash tables if somebody puts a handler in one, so we need
to check whether the hash table exists first, to avoid run-time warnings.

Change-Id: I739d2d808935e651b11bd44b258f168a42ca4b7c
Reviewed-on: https://code.wireshark.org/review/5683
Reviewed-by: Guy Harris <guy@alum.mit.edu>
wiretap/pcapng.c

index 04a46202f44951a8e74ca2c53c7be117830d91de..abbc0c4c93143b2afd764a547eeebbfb9671a166 100644 (file)
@@ -1414,9 +1414,9 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
                 /*
                  * Do we have a handler for this packet block option code?
                  */
-                handler = (option_handler)g_hash_table_lookup(option_handlers[BT_INDEX_PBS],
-                                                              GUINT_TO_POINTER((guint)oh->option_code));
-                if (handler != NULL) {
+                if (option_handlers[BT_INDEX_PBS] != NULL &&
+                    (handler = (option_handler)g_hash_table_lookup(option_handlers[BT_INDEX_PBS],
+                                                                   GUINT_TO_POINTER((guint)oh->option_code))) != NULL) {
                     /* Yes - call the handler. */
                     if (!handler(pn->byte_swapped, oh->option_length,
                                  option_content, err, err_info))