svn commit: samba r16611 - in trunk/source/utils: .

jra at samba.org jra at samba.org
Wed Jun 28 04:51:20 GMT 2006


Author: jra
Date: 2006-06-28 04:51:18 +0000 (Wed, 28 Jun 2006)
New Revision: 16611

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

Log:
Klocwork fix #2011. memleak on error path.
Jeremy.

Modified:
   trunk/source/utils/net_rpc_registry.c


Changeset:
Modified: trunk/source/utils/net_rpc_registry.c
===================================================================
--- trunk/source/utils/net_rpc_registry.c	2006-06-28 04:43:19 UTC (rev 16610)
+++ trunk/source/utils/net_rpc_registry.c	2006-06-28 04:51:18 UTC (rev 16611)
@@ -422,7 +422,7 @@
 
 static int rpc_registry_copy( int argc, const char **argv )
 {
-	REGF_FILE   *infile, *outfile;
+	REGF_FILE   *infile = NULL, *outfile = NULL;
 	REGF_NK_REC *nk;
 	int result = 1;
 	
@@ -441,7 +441,7 @@
 	d_printf("Opening %s....", argv[1]);
 	if ( !(outfile = regfio_open( argv[1], (O_RDWR|O_CREAT|O_TRUNC), (S_IREAD|S_IWRITE) )) ) {
 		d_fprintf(stderr, "Failed to open %s for writing\n", argv[1]);
-		goto out_close_infile;
+		goto out;
 	}
 	d_printf("ok\n");
 	
@@ -449,7 +449,7 @@
 	
 	if ((nk = regfio_rootkey( infile )) == NULL) {
 		d_fprintf(stderr, "Could not get rootkey\n");
-		goto out_close_infile;
+		goto out;
 	}
 	d_printf("RootKey: [%s]\n", nk->keyname);
 
@@ -457,13 +457,18 @@
 
 	result = 0;
 
+out:
+
 	d_printf("Closing %s...", argv[1]);
-	regfio_close( outfile );
+	if (outfile) {
+		regfio_close( outfile );
+	}
 	d_printf("ok\n");
 
-out_close_infile:
 	d_printf("Closing %s...", argv[0]);
-	regfio_close( infile );
+	if (infile) {
+		regfio_close( infile );
+	}
 	d_printf("ok\n");
 
 	return( result);



More information about the samba-cvs mailing list