Don't log warnings if no block-type handlers are registered.
authorGuy Harris <guy@alum.mit.edu>
Tue, 14 Oct 2014 20:41:36 +0000 (13:41 -0700)
committerGuy Harris <guy@alum.mit.edu>
Tue, 14 Oct 2014 20:42:04 +0000 (20:42 +0000)
Check whether the block-type hash table exists before trynig to look
up anything in it.

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

index 5b14294cd38125dbaade55f52c6760cd40eea756..2f5d1ada069ae6a9760715a7d72a9d2ae48170c9 100644 (file)
@@ -2009,9 +2009,9 @@ pcapng_read_unknown_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn _U_
     /*
      * Do we have a handler for this block type?
      */
-    handler = (block_handler *)g_hash_table_lookup(block_handlers,
-                                                   GUINT_TO_POINTER(bh->block_type));
-    if (handler != NULL) {
+    if (block_handlers != NULL &&
+        (handler = (block_handler *)g_hash_table_lookup(block_handlers,
+                                                        GUINT_TO_POINTER(bh->block_type))) != NULL) {
         /* Yes - call it to read this block type. */
         if (!handler->read(fh, block_read, pn->byte_swapped,
                            wblock->packet_header, wblock->frame_buffer,
@@ -3609,9 +3609,9 @@ static gboolean pcapng_dump(wtap_dumper *wdh,
             /*
              * Do we have a handler for this block type?
              */
-            handler = (block_handler *)g_hash_table_lookup(block_handlers,
-                                                           GUINT_TO_POINTER(pseudo_header->ftsrec.record_type));
-            if (handler != NULL) {
+            if (block_handlers != NULL &&
+                (handler = (block_handler *)g_hash_table_lookup(block_handlers,
+                                                                GUINT_TO_POINTER(pseudo_header->ftsrec.record_type))) != NULL) {
                 /* Yes. Call it to write out this record. */
                 if (!handler->write(wdh, phdr, pd, err))
                     return FALSE;