]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/lib/smbconf: replace uses of talloc_tos with talloc_stackframe
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 4 May 2022 14:57:49 +0000 (10:57 -0400)
committerJeremy Allison <jra@samba.org>
Fri, 6 May 2022 17:16:30 +0000 (17:16 +0000)
There are two calls to talloc_tos in the smbconf registry code.
In order not to make callers of this library have to "know" what
calls need an existing talloc stackframe, convert these uses
to match other functions in the same file that already use
talloc_stackframe.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
source3/lib/smbconf/smbconf_reg.c

index c923f3b68201f63233b270b4b81721db9255f3e3..52332ce6dd91a533cc11684817438e10a7dbd6f6 100644 (file)
@@ -180,6 +180,7 @@ static sbcErr smbconf_reg_set_value(struct registry_key *key,
        char *subkeyname;
        const char *canon_valname;
        const char *canon_valstr;
+       TALLOC_CTX *tmp_ctx = talloc_stackframe();
 
        if (!lp_parameter_is_valid(valname)) {
                DEBUG(5, ("Invalid parameter '%s' given.\n", valname));
@@ -229,7 +230,7 @@ static sbcErr smbconf_reg_set_value(struct registry_key *key,
        ZERO_STRUCT(val);
 
        val.type = REG_SZ;
-       if (!push_reg_sz(talloc_tos(), &val.data, canon_valstr)) {
+       if (!push_reg_sz(tmp_ctx, &val.data, canon_valstr)) {
                err = SBC_ERR_NOMEM;
                goto done;
        }
@@ -245,6 +246,7 @@ static sbcErr smbconf_reg_set_value(struct registry_key *key,
 
        err = SBC_ERR_OK;
 done:
+       talloc_free(tmp_ctx);
        return err;
 }
 
@@ -859,15 +861,16 @@ static sbcErr smbconf_reg_create_share(struct smbconf_ctx *ctx,
 {
        sbcErr err;
        struct registry_key *key = NULL;
+       TALLOC_CTX *tmp_ctx = talloc_stackframe();
 
        if (servicename == NULL) {
                return SBC_ERR_OK;
        }
 
-       err = smbconf_reg_create_service_key(talloc_tos(), ctx,
+       err = smbconf_reg_create_service_key(tmp_ctx, ctx,
                                             servicename, &key);
 
-       talloc_free(key);
+       talloc_free(tmp_ctx);
        return err;
 }