r14252: Fix Coverity #72: free alloc'ed storage before return. Also found one
authorJim McDonough <jmcd@samba.org>
Sun, 12 Mar 2006 19:56:10 +0000 (19:56 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:15:21 +0000 (11:15 -0500)
more that coverity didn't find from asprintf.
(This used to be commit 37b6e2c8de41754a5a1a3a6f798d57aa5d533ada)

source3/libads/ldap.c

index dd49c706f46993b8414121232528255a9021ebb1..e1cea533a0e39b027f2de6663462ffe395e19db4 100644 (file)
@@ -1914,7 +1914,10 @@ ADS_STATUS ads_set_machine_sd(ADS_STRUCT *ads, const char *hostname, char *dn)
         * we have to bail out before prs_init */
        ps_wire.is_dynamic = False;
 
-       if (!ads) return ADS_ERROR(LDAP_SERVER_DOWN);
+       if (!ads) {
+               SAFE_FREE(escaped_hostname);
+               return ADS_ERROR(LDAP_SERVER_DOWN);
+       }
 
        ret = ADS_ERROR(LDAP_SUCCESS);
 
@@ -1932,6 +1935,8 @@ ADS_STATUS ads_set_machine_sd(ADS_STRUCT *ads, const char *hostname, char *dn)
 
        ret = ads_search(ads, (void *) &res, expr, attrs);
 
+       SAFE_FREE(expr);
+
        if (!ADS_ERR_OK(ret)) return ret;
 
        if ( !(msg = ads_first_entry(ads, res) )) {