replace one tvb_memdup() with a tvb_memcpy() using an automatically freed emem buffer
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 22 Jul 2005 22:45:36 +0000 (22:45 +0000)
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 22 Jul 2005 22:45:36 +0000 (22:45 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@14998 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-armagetronad.c

index 194e618723e1c36c054af95e984fb845a2f0fd95..a09dfa5f1693d0c19d9e369f457481b799617759 100644 (file)
@@ -30,6 +30,7 @@
 #include <glib.h>
 
 #include <epan/packet.h>
+#include <epan/emem.h>
 
 /* Initialize the protocol and registered fields */
 static int proto_armagetronad = -1;
@@ -142,8 +143,9 @@ add_message_data(tvbuff_t * tvb, gint offset, guint16 data_len,
 {
        guint16 *data = NULL;
 
-       if (tree)
-               data = (guint16 *) tvb_memdup(tvb, offset, data_len);
+       if (tree) {
+               data = (guint16*)tvb_memcpy(tvb, ep_alloc(data_len), offset, data_len);
+       }
 
        if (data) {
                guint16 *ptr, *end = &data[data_len / 2];
@@ -167,7 +169,6 @@ add_message_data(tvbuff_t * tvb, gint offset, guint16 data_len,
                proto_tree_add_string(tree, hf_armagetronad_data, tvb, offset,
                                      data_len, (gchar *) data);
 
-               g_free(data);
                data = NULL;
        } else
                proto_tree_add_item(tree, hf_armagetronad_data, tvb, offset,