svn commit: samba r14099 - branches/SAMBA_3_0/source/utils trunk/source/utils

vlendec at samba.org vlendec at samba.org
Thu Mar 9 20:51:22 GMT 2006


Author: vlendec
Date: 2006-03-09 20:51:22 +0000 (Thu, 09 Mar 2006)
New Revision: 14099

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

Log:
Fix Coverity # 113
Modified:
   branches/SAMBA_3_0/source/utils/net_ads.c
   trunk/source/utils/net_ads.c


Changeset:
Modified: branches/SAMBA_3_0/source/utils/net_ads.c
===================================================================
--- branches/SAMBA_3_0/source/utils/net_ads.c	2006-03-09 20:42:01 UTC (rev 14098)
+++ branches/SAMBA_3_0/source/utils/net_ads.c	2006-03-09 20:51:22 UTC (rev 14099)
@@ -367,17 +367,17 @@
 	}
 
 	escaped_user = escape_ldap_string_alloc(argv[0]);
-	
-	if (!(ads = ads_startup())) {
-		return -1;
-	}
 
 	if (!escaped_user) {
 		d_fprintf(stderr, "ads_user_info: failed to escape user %s\n", argv[0]);
-		ads_destroy(&ads);
-	 	return -1;
+		return -1;
 	}
 
+	if (!(ads = ads_startup())) {
+		SAFE_FREE(escaped_user);
+		return -1;
+	}
+
 	asprintf(&searchstring, "(sAMAccountName=%s)", escaped_user);
 	rc = ads_search(ads, &res, searchstring, attrs);
 	safe_free(searchstring);
@@ -385,6 +385,7 @@
 	if (!ADS_ERR_OK(rc)) {
 		d_fprintf(stderr, "ads_search: %s\n", ads_errstr(rc));
 		ads_destroy(&ads);
+		SAFE_FREE(escaped_user);
 		return -1;
 	}
 	
@@ -403,6 +404,7 @@
 	
 	ads_msgfree(ads, res);
 	ads_destroy(&ads);
+	SAFE_FREE(escaped_user);
 	return 0;
 }
 

Modified: trunk/source/utils/net_ads.c
===================================================================
--- trunk/source/utils/net_ads.c	2006-03-09 20:42:01 UTC (rev 14098)
+++ trunk/source/utils/net_ads.c	2006-03-09 20:51:22 UTC (rev 14099)
@@ -367,17 +367,17 @@
 	}
 
 	escaped_user = escape_ldap_string_alloc(argv[0]);
-	
-	if (!(ads = ads_startup())) {
-		return -1;
-	}
 
 	if (!escaped_user) {
 		d_fprintf(stderr, "ads_user_info: failed to escape user %s\n", argv[0]);
-		ads_destroy(&ads);
-	 	return -1;
+		return -1;
 	}
 
+	if (!(ads = ads_startup())) {
+		SAFE_FREE(escaped_user);
+		return -1;
+	}
+
 	asprintf(&searchstring, "(sAMAccountName=%s)", escaped_user);
 	rc = ads_search(ads, &res, searchstring, attrs);
 	safe_free(searchstring);
@@ -385,6 +385,7 @@
 	if (!ADS_ERR_OK(rc)) {
 		d_fprintf(stderr, "ads_search: %s\n", ads_errstr(rc));
 		ads_destroy(&ads);
+		SAFE_FREE(escaped_user);
 		return -1;
 	}
 	
@@ -403,6 +404,7 @@
 	
 	ads_msgfree(ads, res);
 	ads_destroy(&ads);
+	SAFE_FREE(escaped_user);
 	return 0;
 }
 



More information about the samba-cvs mailing list