convert some tvb_fake_unicode() to tvb_get_ephemeral_faked_unicode()
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 10 Aug 2005 14:17:27 +0000 (14:17 +0000)
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 10 Aug 2005 14:17:27 +0000 (14:17 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15272 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-dcerpc-nt.c
epan/dissectors/packet-gsm_sms.c
epan/dissectors/packet-kerberos.c
epan/dissectors/packet-ms-mms.c
epan/dissectors/packet-ntlmssp.c
epan/dissectors/packet-per.c
epan/dissectors/packet-srvloc.c

index 7033a80473aad484a451a65b119865ff1cb9c4f2..2f1eaa45fe460f327dbd0bb07dcf26d3157acf13 100644 (file)
@@ -986,7 +986,6 @@ dissect_ndr_uint16s(tvbuff_t *tvb, gint offset, packet_info *pinfo,
 /*
  * Helper routines for dissecting NDR strings
  */
-
 void cb_wstr_postprocess(packet_info *pinfo, proto_tree *tree _U_,
                        proto_item *item, tvbuff_t *tvb, 
                        int start_offset, int end_offset,
@@ -1014,7 +1013,7 @@ void cb_wstr_postprocess(packet_info *pinfo, proto_tree *tree _U_,
         * some way we can get that string, rather than duplicating the
         * efforts of that routine?
         */
-       s = tvb_fake_unicode(
+       s = tvb_get_ephemeral_faked_unicode(
                tvb, start_offset + 12, (end_offset - start_offset - 12) / 2,
                TRUE);
 
@@ -1049,10 +1048,9 @@ void cb_wstr_postprocess(packet_info *pinfo, proto_tree *tree _U_,
                dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
                dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data;
                
+/* FIXME EPHEMERAL need to get rid of the g_strdup() and later g_free() */
                dcv->private_data = g_strdup(s);
        }
-
-       g_free(s);
 }
 
 void cb_str_postprocess(packet_info *pinfo, proto_tree *tree _U_,
index fff7a72a3fd4ea21dc81577cd99df3993228b8d8..266dbe43c6f1222c472e9b49d19c3c1a4d77e8cd 100644 (file)
@@ -1852,10 +1852,9 @@ dis_field_ud(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint32 length, gb
                }
                else if (ucs2)
                        {
-                       /* tvb_fake_unicode takes the lengt in number of guint16's */
-                       ustr = tvb_fake_unicode(tvb, offset, (length>>1), FALSE);
+                       /* tvb_get_ephemeral_faked_unicode takes the lengt in number of guint16's */
+                       ustr = tvb_get_ephemeral_faked_unicode(tvb, offset, (length>>1), FALSE);
                        proto_tree_add_text(subtree, tvb, offset, length, "%s", ustr);
-                       g_free(ustr);
                }
     }
 }
index 740b2bd35b54aa96f18bc6ba72c2f12ebde619fe..6abd9fe14e3c283806d59a38fd5ca972708ea3d3 100644 (file)
@@ -2323,9 +2323,8 @@ dissect_krb5_PAC_CLIENT_INFO_TYPE(packet_info *pinfo _U_, proto_tree *parent_tre
        offset+=2;
 
        /* client name */
-       name=tvb_fake_unicode(tvb, offset, namelen/2, TRUE);
+       name=tvb_get_ephemeral_faked_unicode(tvb, offset, namelen/2, TRUE);
        proto_tree_add_string(tree, hf_krb_pac_clientname, tvb, offset, namelen, name);
-       g_free(name);
        offset+=namelen;
 
        return offset;
index 91676db384591719f6ec944876d7545644beb277..8d7a5e92fd7474d08751c643320d17064e379101 100644 (file)
@@ -787,7 +787,7 @@ void dissect_client_transport_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree
     offset += 4;
 
     /* Extract and show the string in tree and info column */
-    transport_info = tvb_fake_unicode(tvb, offset, (length_remaining - 20)/2, TRUE);
+    transport_info = tvb_get_ephemeral_faked_unicode(tvb, offset, (length_remaining - 20)/2, TRUE);
 
     proto_tree_add_string_format(tree, hf_msmms_command_client_transport_info, tvb,
                                  offset, length_remaining-20,
@@ -836,9 +836,6 @@ void dissect_client_transport_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree
             msmms_data_add_address(pinfo, &addr, pt, port);
         }
     }
-
-    /* Can now free this string */
-    g_free(transport_info);
 }
 
 /* Dissect server data */
@@ -902,7 +899,7 @@ void dissect_server_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
     /* Server version string */
     if (server_version_length > 1)
     {
-        server_version = tvb_fake_unicode(tvb, offset, server_version_length, TRUE);
+        server_version = tvb_get_ephemeral_faked_unicode(tvb, offset, server_version_length, TRUE);
 
         /* Server version string */
         proto_tree_add_string(tree, hf_msmms_command_server_version, tvb,
@@ -914,10 +911,6 @@ void dissect_server_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
             col_append_fstr(pinfo->cinfo, COL_INFO, " (version='%s')",
                            format_text(server_version, server_version_length));
         }
-
-
-        /* Can now free this string */
-        g_free(server_version);
     }
     offset += (server_version_length*2);
 
@@ -925,43 +918,34 @@ void dissect_server_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
     /* Tool version string */
     if (tool_version_length > 1)
     {
-        tool_version = tvb_fake_unicode(tvb, offset, tool_version_length, TRUE);
+        tool_version = tvb_get_ephemeral_faked_unicode(tvb, offset, tool_version_length, TRUE);
 
         /* Server version string */
         proto_tree_add_string(tree, hf_msmms_command_tool_version, tvb,
                               offset, tool_version_length*2,
                               format_text(tool_version, tool_version_length));
-
-        /* Can now free this string */
-        g_free(tool_version);
     }
     offset += (tool_version_length*2);
 
     /* Download update player url string */
     if (download_update_player_length > 1)
     {
-        download_update_player = tvb_fake_unicode(tvb, offset, download_update_player_length, TRUE);
+        download_update_player = tvb_get_ephemeral_faked_unicode(tvb, offset, download_update_player_length, TRUE);
 
         proto_tree_add_string(tree, hf_msmms_command_update_url, tvb,
                               offset, download_update_player_length*2,
                               download_update_player);
-
-        /* Can now free this string */
-        g_free(download_update_player);
     }
     offset += (download_update_player_length*2);
 
     /* Password encryption type string */
     if (password_encryption_type_length > 1)
     {
-        password_encryption_type = tvb_fake_unicode(tvb, offset, password_encryption_type_length, TRUE);
+        password_encryption_type = tvb_get_ephemeral_faked_unicode(tvb, offset, password_encryption_type_length, TRUE);
 
         proto_tree_add_string(tree, hf_msmms_command_password_type, tvb,
                               offset, password_encryption_type_length*2,
                               password_encryption_type);
-
-        /* Can now free this string */
-        g_free(password_encryption_type);
     }
     offset += (password_encryption_type_length*2);
 
@@ -984,7 +968,7 @@ void dissect_client_player_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t
     offset += 4;
 
     /* Extract and show the string in tree and info column */
-    player_info = tvb_fake_unicode(tvb, offset, (length_remaining - 12)/2, TRUE);
+    player_info = tvb_get_ephemeral_faked_unicode(tvb, offset, (length_remaining - 12)/2, TRUE);
 
     proto_tree_add_string(tree, hf_msmms_command_client_player_info, tvb,
                           offset, length_remaining-12,
@@ -995,9 +979,6 @@ void dissect_client_player_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t
         col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)",
                         format_text(player_info, (length_remaining - 12)/2));
     }
-
-    /* Can now free this string */
-    g_free(player_info);
 }
 
 /* Dissect info about where client wants to start playing from */
@@ -1101,7 +1082,7 @@ void dissect_request_server_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *
     offset += 4;
 
     /* File path on server */
-    server_file = tvb_fake_unicode(tvb, offset, (length_remaining - 16)/2, TRUE);
+    server_file = tvb_get_ephemeral_faked_unicode(tvb, offset, (length_remaining - 16)/2, TRUE);
 
     proto_tree_add_string(tree, hf_msmms_command_server_file, tvb,
                           offset, length_remaining-16,
@@ -1112,9 +1093,6 @@ void dissect_request_server_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *
         col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)",
                         format_text(server_file, (length_remaining - 16)/2));
     }
-
-    /* Can now free this string */
-    g_free(server_file);
 }
 
 /* Dissect media details from server */
@@ -1207,14 +1185,11 @@ void dissect_transport_info_response(tvbuff_t *tvb, proto_tree *tree,
     offset += 4;
 
     /* Read this strange string */
-    strange_string = tvb_fake_unicode(tvb, offset, (length_remaining - 12)/2, TRUE);
+    strange_string = tvb_get_ephemeral_faked_unicode(tvb, offset, (length_remaining - 12)/2, TRUE);
 
     proto_tree_add_string(tree, hf_msmms_command_strange_string, tvb,
                           offset, length_remaining-12,
                           strange_string);
-
-    /* Can now free this string */
-    g_free(strange_string);
 }
 
 /* Media stream MBR selector */
index 1a48a3ef7fe28b6695762960379477a782c0dfd0..7181aa8aeac76a7c74931f01bdb54aa9a8ac8822 100644 (file)
@@ -694,14 +694,14 @@ dissect_ntlmv2_response(tvbuff_t *tvb, proto_tree *tree, int offset, int len)
                /* Dissect name */
 
                if (name_len > 0) {
-                       name = tvb_fake_unicode(
+                       name = tvb_get_ephemeral_faked_unicode(
                                tvb, offset, name_len / 2, TRUE);
 
                        proto_tree_add_text(
                                name_tree, tvb, offset, name_len, 
                                "Name: %s", name);
                } else
-                       name = g_strdup("NULL");
+                       name = "NULL";
 
                if (name_type == 0)
                        proto_item_append_text(
@@ -714,8 +714,6 @@ dissect_ntlmv2_response(tvbuff_t *tvb, proto_tree *tree, int offset, int len)
                                val_to_str(name_type, ntlm_name_types,
                                           "Unknown"), name);
 
-               g_free(name);
-
                offset += name_len;
 
                proto_item_set_len(name_item, name_len + 4);
index e6c29ec986cb1cefd578a9ecf916396849c22c29..f5007ddc9a8bdaeb5b893650af03e342082d1fe4 100644 (file)
@@ -484,10 +484,9 @@ dissect_per_BMPString(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_t
                length=1024;
        }
 
-       str = tvb_fake_unicode(tvb, offset>>3, length, FALSE);
+       str = tvb_get_ephemeral_faked_unicode(tvb, offset>>3, length, FALSE);
 
        proto_tree_add_string(tree, hf_index, tvb, offset>>3, length*2, str);
-       g_free(str);
 
        offset+=(length<<3)*2;
 
index c4dee7ee27c559c054db0956bfe2b3e456561334..56dd72ce6c4fa242e2f3d00a467ebab62d59f819 100644 (file)
@@ -414,10 +414,9 @@ add_v1_string(proto_tree *tree, int hf, tvbuff_t *tvb, int offset, int length,
         switch (encoding) {
 
         case CHARSET_ISO_10646_UCS_2:
-                unicode_str = tvb_fake_unicode(tvb, offset, length/2, FALSE);
+                unicode_str = tvb_get_ephemeral_faked_unicode(tvb, offset, length/2, FALSE);
                 proto_tree_add_string(tree, hf, tvb, offset, length,
                                     unicode_str);
-                g_free(unicode_str);
                 break;
 
         default:
@@ -508,12 +507,10 @@ attr_list(proto_tree *tree, int hf, tvbuff_t *tvb, int offset, int length,
 
     case CHARSET_ISO_10646_UCS_2:
 
-        tmp = tvb_fake_unicode(tvb, offset, length/2, FALSE);
+        tmp = tvb_get_ephemeral_faked_unicode(tvb, offset, length/2, FALSE);
         type_len = strcspn(tmp, "=");
-        g_free(tmp);
-        attr_type = tvb_fake_unicode(tvb, offset+2, type_len-1, FALSE);
+        attr_type = tvb_get_ephemeral_faked_unicode(tvb, offset+2, type_len-1, FALSE);
         proto_tree_add_string(tree, hf, tvb, offset, type_len*2, attr_type);
-        g_free(attr_type);
         i=1;
         for (foffset = offset + ((type_len*2)+2); foffset<length; foffset += 2) {