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

vlendec at samba.org vlendec at samba.org
Thu Mar 9 20:42:04 GMT 2006


Author: vlendec
Date: 2006-03-09 20:42:01 +0000 (Thu, 09 Mar 2006)
New Revision: 14098

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

Log:
Fix Coverity # 112
Modified:
   branches/SAMBA_3_0/source/utils/net.c
   trunk/source/utils/net.c


Changeset:
Modified: branches/SAMBA_3_0/source/utils/net.c
===================================================================
--- branches/SAMBA_3_0/source/utils/net.c	2006-03-09 20:41:59 UTC (rev 14097)
+++ branches/SAMBA_3_0/source/utils/net.c	2006-03-09 20:42:01 UTC (rev 14098)
@@ -249,12 +249,21 @@
 	struct cli_state *cli_tmp = NULL;
 	struct rpc_pipe_client *pipe_hnd = NULL;
 
-	if (opt_destination)
-		server_name = SMB_STRDUP(opt_destination);
+	if (server_name == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
 
+	if (opt_destination) {
+		SAFE_FREE(server_name);
+		if ((server_name = SMB_STRDUP(opt_destination)) == NULL) {
+			return NT_STATUS_NO_MEMORY;
+		}
+	}
+
 	/* make a connection to a named pipe */
 	nt_status = connect_to_ipc(&cli_tmp, NULL, server_name);
 	if (!NT_STATUS_IS_OK(nt_status)) {
+		SAFE_FREE(server_name);
 		return nt_status;
 	}
 
@@ -262,11 +271,13 @@
 	if (!pipe_hnd) {
 		DEBUG(0, ("couldn't not initialize pipe\n"));
 		cli_shutdown(cli_tmp);
+		SAFE_FREE(server_name);
 		return nt_status;
 	}
 
 	*cli_dst = cli_tmp;
 	*pp_pipe_hnd = pipe_hnd;
+	SAFE_FREE(server_name);
 
 	return nt_status;
 }

Modified: trunk/source/utils/net.c
===================================================================
--- trunk/source/utils/net.c	2006-03-09 20:41:59 UTC (rev 14097)
+++ trunk/source/utils/net.c	2006-03-09 20:42:01 UTC (rev 14098)
@@ -249,12 +249,21 @@
 	struct cli_state *cli_tmp = NULL;
 	struct rpc_pipe_client *pipe_hnd = NULL;
 
-	if (opt_destination)
-		server_name = SMB_STRDUP(opt_destination);
+	if (server_name == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
 
+	if (opt_destination) {
+		SAFE_FREE(server_name);
+		if ((server_name = SMB_STRDUP(opt_destination)) == NULL) {
+			return NT_STATUS_NO_MEMORY;
+		}
+	}
+
 	/* make a connection to a named pipe */
 	nt_status = connect_to_ipc(&cli_tmp, NULL, server_name);
 	if (!NT_STATUS_IS_OK(nt_status)) {
+		SAFE_FREE(server_name);
 		return nt_status;
 	}
 
@@ -262,11 +271,13 @@
 	if (!pipe_hnd) {
 		DEBUG(0, ("couldn't not initialize pipe\n"));
 		cli_shutdown(cli_tmp);
+		SAFE_FREE(server_name);
 		return nt_status;
 	}
 
 	*cli_dst = cli_tmp;
 	*pp_pipe_hnd = pipe_hnd;
+	SAFE_FREE(server_name);
 
 	return nt_status;
 }



More information about the samba-cvs mailing list