Author: jmcd
Date: 2006-03-12 19:56:10 +0000 (Sun, 12 Mar 2006)
New Revision: 14252

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=14252

Log:
Fix Coverity #72: free alloc'ed storage before return.  Also found one
more that coverity didn't find from asprintf.

Modified:
   branches/SAMBA_3_0/source/libads/ldap.c
   trunk/source/libads/ldap.c


Changeset:
Modified: branches/SAMBA_3_0/source/libads/ldap.c
===================================================================
--- branches/SAMBA_3_0/source/libads/ldap.c     2006-03-12 19:16:57 UTC (rev 
14251)
+++ branches/SAMBA_3_0/source/libads/ldap.c     2006-03-12 19:56:10 UTC (rev 
14252)
@@ -1914,7 +1914,10 @@
         * 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 @@
 
        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) )) {

Modified: trunk/source/libads/ldap.c
===================================================================
--- trunk/source/libads/ldap.c  2006-03-12 19:16:57 UTC (rev 14251)
+++ trunk/source/libads/ldap.c  2006-03-12 19:56:10 UTC (rev 14252)
@@ -1914,7 +1914,10 @@
         * 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 @@
 
        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) )) {

Reply via email to