summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2012-04-23 15:47:33 +0200
committerAndreas Schneider <asn@samba.org>2012-04-25 14:31:12 +0200
commit1703e6fe096ea9e3e14c189522150321fee1a4c5 (patch)
tree1de20f75c5350c7a0dcbee726aa4c0b2bb8b17be /source3/registry
parent323ec9f9b46edb5792bd0695955184e4111e9a34 (diff)
downloadsamba-1703e6fe096ea9e3e14c189522150321fee1a4c5.tar.gz
samba-1703e6fe096ea9e3e14c189522150321fee1a4c5.tar.bz2
samba-1703e6fe096ea9e3e14c189522150321fee1a4c5.zip
s3:registry: convert reg_openkey() to use talloc instead of SMB_STRDUP etc
Signed-off-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_api.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c
index ff70016ae2..ba5fb313c5 100644
--- a/source3/registry/reg_api.c
+++ b/source3/registry/reg_api.c
@@ -260,13 +260,15 @@ WERROR reg_openkey(TALLOC_CTX *mem_ctx, struct registry_key *parent,
{
struct registry_key *direct_parent = parent;
WERROR err;
- char *p, *path, *to_free;
+ char *p, *path;
size_t len;
+ TALLOC_CTX *frame = talloc_stackframe();
- if (!(path = SMB_STRDUP(name))) {
- return WERR_NOMEM;
+ path = talloc_strdup(frame, name);
+ if (path == NULL) {
+ err = WERR_NOMEM;
+ goto error;
}
- to_free = path;
len = strlen(path);
@@ -278,22 +280,19 @@ WERROR reg_openkey(TALLOC_CTX *mem_ctx, struct registry_key *parent,
char *name_component;
struct registry_key *tmp;
- if (!(name_component = SMB_STRNDUP(path, (p - path)))) {
+ name_component = talloc_strndup(frame, path, (p - path));
+ if (name_component == NULL) {
err = WERR_NOMEM;
goto error;
}
- err = regkey_open_onelevel(mem_ctx, direct_parent,
+ err = regkey_open_onelevel(frame, direct_parent,
name_component, parent->token,
KEY_ENUMERATE_SUB_KEYS, &tmp);
- SAFE_FREE(name_component);
if (!W_ERROR_IS_OK(err)) {
goto error;
}
- if (direct_parent != parent) {
- TALLOC_FREE(direct_parent);
- }
direct_parent = tmp;
path = p+1;
@@ -301,11 +300,9 @@ WERROR reg_openkey(TALLOC_CTX *mem_ctx, struct registry_key *parent,
err = regkey_open_onelevel(mem_ctx, direct_parent, path, parent->token,
desired_access, pkey);
- error:
- if (direct_parent != parent) {
- TALLOC_FREE(direct_parent);
- }
- SAFE_FREE(to_free);
+
+error:
+ talloc_free(frame);
return err;
}