s3-secrets: Use talloc_stackframe() in secrets_init_path()
authorAndrew Bartlett <abartlet@samba.org>
Mon, 27 Aug 2012 09:42:44 +0000 (19:42 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 27 Aug 2012 21:57:29 +0000 (07:57 +1000)
source3/passdb/secrets.c

index dff855cce6327cf696fc481d22e630707c89baa1..8f314a76cf574c504d47d1666fb858da7f63ca90 100644 (file)
@@ -59,6 +59,7 @@ bool secrets_init_path(const char *private_dir)
 {
        char *fname = NULL;
        unsigned char dummy;
+       TALLOC_CTX *frame;
 
        if (db_ctx != NULL) {
                return True;
@@ -68,9 +69,11 @@ bool secrets_init_path(const char *private_dir)
                return False;
        }
 
-       fname = talloc_asprintf(talloc_tos(), "%s/secrets.tdb",
+       frame = talloc_stackframe();
+       fname = talloc_asprintf(frame, "%s/secrets.tdb",
                                private_dir);
        if (fname == NULL) {
+               TALLOC_FREE(frame);
                return False;
        }
 
@@ -80,11 +83,10 @@ bool secrets_init_path(const char *private_dir)
 
        if (db_ctx == NULL) {
                DEBUG(0,("Failed to open %s\n", fname));
+               TALLOC_FREE(frame);
                return False;
        }
 
-       TALLOC_FREE(fname);
-
        /**
         * Set a reseed function for the crypto random generator
         *
@@ -96,6 +98,7 @@ bool secrets_init_path(const char *private_dir)
        /* Ensure that the reseed is done now, while we are root, etc */
        generate_random_buffer(&dummy, sizeof(dummy));
 
+       TALLOC_FREE(frame);
        return True;
 }