make dissect_nt_sid return ep allocated memory and thus fix a few memory leaks
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 16 Sep 2006 09:20:34 +0000 (09:20 +0000)
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 16 Sep 2006 09:20:34 +0000 (09:20 +0000)
(this function is often called from dcerpc dissectors)

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@19243 f5534014-38df-0310-8fa8-9805f1628bb7

asn1/ldap/packet-ldap-template.c
epan/dissectors/packet-ldap.c
epan/dissectors/packet-windows-common.c

index a8e3271802494e82d4eb6cb60ecba1a8032b29f0..0ace0ae43c8bcb4c3dc83399675f2ba1fbbbfd29 100644 (file)
@@ -305,8 +305,7 @@ dissect_ldap_AssertionValue(gboolean implicit_tag, tvbuff_t *tvb, int offset, pa
                /* this octet string contains an NT SID */
                sid_tvb=tvb_new_subset(tvb, offset, len, len);
                dissect_nt_sid(sid_tvb, 0, tree, "SID", &tmpstr, hf_index);
-               ldapvalue_string=ep_strdup(tmpstr);
-               g_free(tmpstr);
+               ldapvalue_string=tmpstr;
 
                goto finished;
        } else if ( (len==16) /* GUIDs are always 16 bytes */
@@ -1273,8 +1272,7 @@ dissect_ldap_sid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
        /* this octet string contains an NT SID */
        dissect_nt_sid(tvb, 0, tree, "SID", &tmpstr, hf_ldap_sid);
-       ldapvalue_string=ep_strdup(tmpstr);
-       g_free(tmpstr);
+       ldapvalue_string=tmpstr;
 }
 
 static void
index bef6e2c6c2ec83a36854fe050d2b3a0aa2ee4cb2..f6722db08d6f8e2837360f1e4f720dc6002fd354 100644 (file)
@@ -457,8 +457,7 @@ dissect_ldap_AssertionValue(gboolean implicit_tag, tvbuff_t *tvb, int offset, pa
                /* this octet string contains an NT SID */
                sid_tvb=tvb_new_subset(tvb, offset, len, len);
                dissect_nt_sid(sid_tvb, 0, tree, "SID", &tmpstr, hf_index);
-               ldapvalue_string=ep_strdup(tmpstr);
-               g_free(tmpstr);
+               ldapvalue_string=tmpstr;
 
                goto finished;
        } else if ( (len==16) /* GUIDs are always 16 bytes */
@@ -2774,7 +2773,7 @@ static void dissect_LDAPMessage_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tre
 
 
 /*--- End of included file: packet-ldap-fn.c ---*/
-#line 539 "packet-ldap-template.c"
+#line 538 "packet-ldap-template.c"
 
 static void
 dissect_ldap_payload(tvbuff_t *tvb, packet_info *pinfo,
@@ -3512,8 +3511,7 @@ dissect_ldap_sid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
        /* this octet string contains an NT SID */
        dissect_nt_sid(tvb, 0, tree, "SID", &tmpstr, hf_ldap_sid);
-       ldapvalue_string=ep_strdup(tmpstr);
-       g_free(tmpstr);
+       ldapvalue_string=tmpstr;
 }
 
 static void
@@ -4224,7 +4222,7 @@ void proto_register_ldap(void) {
         "ldap.OCTET_STRING", HFILL }},
 
 /*--- End of included file: packet-ldap-hfarr.c ---*/
-#line 1596 "packet-ldap-template.c"
+#line 1594 "packet-ldap-template.c"
   };
 
   /* List of subtrees */
@@ -4277,7 +4275,7 @@ void proto_register_ldap(void) {
     &ett_ldap_ExtendedResponse,
 
 /*--- End of included file: packet-ldap-ettarr.c ---*/
-#line 1607 "packet-ldap-template.c"
+#line 1605 "packet-ldap-template.c"
   };
 
     module_t *ldap_module;
index 3ad85383d80f9139f7b5b4333884a33047300459..41eda822ab3dba3e12ffbfb2e31b4bd743710cae 100644 (file)
@@ -1,6 +1,3 @@
-/* TODO: dissect_nt_sid() should be changed to return ep memory
- * and not gmalloc memory.
- */
 /* packet-windows-common.c
  * Routines for dissecting various Windows data types
  *
@@ -1385,15 +1382,15 @@ dissect_nt_sid(tvbuff_t *tvb, int offset, proto_tree *parent_tree,
 
           if(sid_str){
             if(sid_name){
-              *sid_str = g_strdup_printf("%s (%s)", sid_string, sid_name);
+              *sid_str = ep_strdup_printf("%s (%s)", sid_string, sid_name);
             } else {
-              *sid_str = g_strdup(sid_string);
+              *sid_str = ep_strdup(sid_string);
             }
           }
        }
 
        if(sid_str && !(*sid_str)){
-               *sid_str=g_strdup("corrupted sid");
+               *sid_str=ep_strdup("corrupted sid");
        }
 
        return offset;
@@ -1946,9 +1943,6 @@ dissect_nt_v2_ace(tvbuff_t *tvb, int offset, packet_info *pinfo,
                                item, "%s, flags 0x%02x, %s, mask 0x%08x", sid_str, flags,
                                val_to_str(type, ace_type_vals, "Unknown ACE type (0x%02x)"),
                                perms);
-               if(sid_str){
-                       g_free(sid_str);
-               }
                break;
        };