Correctly free memory in regfio paths
authorAlexander Bokovoy <ab@samba.org>
Mon, 15 Oct 2007 03:24:44 +0000 (07:24 +0400)
committerGerald (Jerry) Carter <jerry@samba.org>
Mon, 15 Oct 2007 22:41:09 +0000 (17:41 -0500)
(This used to be commit 97f9a90b823887e808cca96eca7a041f121e6111)

source3/registry/regfio.c
source3/utils/profiles.c

index 6dca0ba86206709fd4dfbdaba2be4ba4cc80e306..93a27700b3b22d7981d5a54ab6f5cbf3c48c1291 100644 (file)
@@ -1171,6 +1171,7 @@ out:
        
        if ( !(rb->mem_ctx = talloc_init( "read_regf_block" )) ) {
                regfio_close( rb );
+               SAFE_FREE(rb);
                return NULL;
        }
 
@@ -1181,6 +1182,7 @@ out:
        if ( (rb->fd = open(filename, flags, mode)) == -1 ) {
                DEBUG(0,("regfio_open: failure to open %s (%s)\n", filename, strerror(errno)));
                regfio_close( rb );
+               SAFE_FREE(rb);
                return NULL;
        }
        
@@ -1190,6 +1192,7 @@ out:
                if ( !init_regf_block( rb ) ) {
                        DEBUG(0,("regfio_open: Failed to read initial REGF block\n"));
                        regfio_close( rb );
+                       SAFE_FREE(rb);
                        return NULL;
                }
                
@@ -1202,6 +1205,7 @@ out:
        if ( !read_regf_block( rb ) ) {
                DEBUG(0,("regfio_open: Failed to read initial REGF block\n"));
                regfio_close( rb );
+               SAFE_FREE(rb);
                return NULL;
        }
        
index 7c7b91adb1c6e1d68242b45278362d6761705f1c..921af566576954634420b2fa66d60e87b1ca8ded 100644 (file)
@@ -138,6 +138,7 @@ static BOOL copy_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
        }
 
        if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) {
+               TALLOC_FREE( subkeys );
                DEBUG(0,("copy_registry_tree: talloc() failure!\n"));
                return False;
        }
@@ -163,8 +164,10 @@ static BOOL copy_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
        
        nk->subkey_index = 0;
        while ( (subkey = regfio_fetch_subkey( infile, nk )) ) {
-               if ( !copy_registry_tree( infile, subkey, key, outfile, path ) )
+               if ( !copy_registry_tree( infile, subkey, key, outfile, path ) ) {
+                       TALLOC_FREE( subkeys );
                        return False;
+               }
        }
 
        /* values is a talloc()'d child of subkeys here so just throw it all away */