Fix CID 1111806: it's not safe to check if "tag < sizeof(tag_to_type)" before
[metze/wireshark/wip.git] / epan / next_tvb.c
index e35c47ff73e786354ab26cdaded720ab9276d982..9297e53b60fa71d0999b8f553c1cbc981915ed6f 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
 
 #include <glib.h>
 
@@ -42,7 +40,7 @@ void next_tvb_init(next_tvb_list_t *list) {
 void next_tvb_add_handle(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, dissector_handle_t handle) {
   next_tvb_item_t *item;
 
-  item = ep_alloc(sizeof(next_tvb_item_t));
+  item = ep_new(next_tvb_item_t);
 
   item->type = NTVB_HANDLE;
   item->handle = handle;
@@ -60,14 +58,14 @@ void next_tvb_add_handle(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree,
   list->count++;
 }
 
-void next_tvb_add_port(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, dissector_table_t table, guint32 port) {
+void next_tvb_add_uint(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, dissector_table_t table, guint32 uint_val) {
   next_tvb_item_t *item;
 
-  item = ep_alloc(sizeof(next_tvb_item_t));
+  item = ep_new(next_tvb_item_t);
 
-  item->type = NTVB_PORT;
+  item->type = NTVB_UINT;
   item->table = table;
-  item->port = port;
+  item->uint_val = uint_val;
   item->tvb = tvb;
   item->tree = tree;
 
@@ -85,7 +83,7 @@ void next_tvb_add_port(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, d
 void next_tvb_add_string(next_tvb_list_t *list, tvbuff_t *tvb, proto_tree *tree, dissector_table_t table, const gchar *string) {
   next_tvb_item_t *item;
 
-  item = ep_alloc(sizeof(next_tvb_item_t));
+  item = ep_new(next_tvb_item_t);
 
   item->type = NTVB_STRING;
   item->table = table;
@@ -114,8 +112,8 @@ void next_tvb_call(next_tvb_list_t *list, packet_info *pinfo, proto_tree *tree,
         case NTVB_HANDLE:
           call_dissector((item->handle) ? item->handle : ((handle) ? handle : data_handle), item->tvb, pinfo, (item->tree) ? item->tree : tree);
           break;
-        case NTVB_PORT:
-          dissector_try_port(item->table, item->port, item->tvb, pinfo, (item->tree) ? item->tree : tree);
+        case NTVB_UINT:
+          dissector_try_uint(item->table, item->uint_val, item->tvb, pinfo, (item->tree) ? item->tree : tree);
           break;
         case NTVB_STRING:
           dissector_try_string(item->table, item->string, item->tvb, pinfo, (item->tree) ? item->tree : tree);