summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-06-28 04:51:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:19:03 -0500
commit8413a18a58a9f00f440b4252cb671976adcf8b7b (patch)
treebe708e62e867b9cc199124a126e30999e09a77c3 /source3/utils
parent61578c2308f7e3bbeca6e5effb29cebee5e17e8e (diff)
downloadsamba-8413a18a58a9f00f440b4252cb671976adcf8b7b.tar.gz
samba-8413a18a58a9f00f440b4252cb671976adcf8b7b.tar.bz2
samba-8413a18a58a9f00f440b4252cb671976adcf8b7b.zip
r16612: Klocwork fix #2011. memleak on error path.
Jeremy. (This used to be commit b4e9475d2ac65f72cab0d5c8276da27cf1aeb791)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_rpc_registry.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c
index 10ba28e023..1b62adc60f 100644
--- a/source3/utils/net_rpc_registry.c
+++ b/source3/utils/net_rpc_registry.c
@@ -433,7 +433,7 @@ static int rpc_registry_dump( int argc, const char **argv )
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;
@@ -452,7 +452,7 @@ static int rpc_registry_copy( int argc, const char **argv )
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");
@@ -460,7 +460,7 @@ static int rpc_registry_copy( int argc, const char **argv )
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);
@@ -468,13 +468,18 @@ static int rpc_registry_copy( int argc, const char **argv )
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);