Don't dereference a NULL pointer. Fixes CID 426.
[obnox/wireshark/wip.git] / plugins / ethercat / packet-ethercat-frame.c
index 0369b60c70fdb3cea2acbabff11ed995bc38c684..ba0669e394bf29fdca54e051282292a39e4973bb 100644 (file)
@@ -94,15 +94,12 @@ static void dissect_ethercat_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree
       handle the rest of the PDU. */
    next_tvb = tvb_new_subset_remaining (tvb, offset);
 
-   if (!dissector_try_port(ethercat_frame_dissector_table, hdr.v.protocol,
+   if (!dissector_try_uint(ethercat_frame_dissector_table, hdr.v.protocol,
        next_tvb, pinfo, tree))
    {
-      if (check_col (pinfo->cinfo, COL_PROTOCOL))
-      {
-         col_add_fstr (pinfo->cinfo, COL_PROTOCOL, "0x%04x", hdr.v.protocol);
-      }
+      col_add_fstr (pinfo->cinfo, COL_PROTOCOL, "0x%04x", hdr.v.protocol);
       /* No sub dissector wanted to handle this payload, decode it as general
-         data instead. */
+      data instead. */
       call_dissector (ethercat_frame_data_handle, next_tvb, pinfo, tree);
    }
 }
@@ -119,7 +116,7 @@ void proto_register_ethercat_frame(void)
 
       { &hf_ethercat_frame_reserved,
       { "Reserved", "ecatf.reserved",
-      FT_UINT16, BASE_HEX, VALS(&ethercat_frame_reserved_vals), 0x0800,
+      FT_UINT16, BASE_HEX, VALS(ethercat_frame_reserved_vals), 0x0800,
       NULL, HFILL}
       },
 
@@ -153,8 +150,8 @@ void proto_reg_handoff_ethercat_frame(void)
    dissector_handle_t ethercat_frame_handle;
 
    ethercat_frame_handle = find_dissector("ecatf");
-   dissector_add("ethertype", ETHERTYPE_ECATF, ethercat_frame_handle);
-   dissector_add("udp.port", ETHERTYPE_ECATF, ethercat_frame_handle);
-   dissector_add("tcp.port", ETHERTYPE_ECATF, ethercat_frame_handle);
+   dissector_add_uint("ethertype", ETHERTYPE_ECATF, ethercat_frame_handle);
+   dissector_add_uint("udp.port", ETHERTYPE_ECATF, ethercat_frame_handle);
+   dissector_add_uint("tcp.port", ETHERTYPE_ECATF, ethercat_frame_handle);
    ethercat_frame_data_handle = find_dissector("data");
 }