summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorWilco Baan Hofman <wilco@baanhofman.nl>2010-01-19 12:06:01 +0100
committerJelmer Vernooij <jelmer@samba.org>2010-01-20 09:59:18 +1300
commit8067bf629c4c4a2a4c1e66af41fc387448d468c6 (patch)
tree249895bb94d823c04bd1668083e6071e033538de /source4/lib
parentf8314c27b3804dc95c973f1577e3e40d7c91ae43 (diff)
downloadsamba-8067bf629c4c4a2a4c1e66af41fc387448d468c6.tar.gz
samba-8067bf629c4c4a2a4c1e66af41fc387448d468c6.tar.bz2
samba-8067bf629c4c4a2a4c1e66af41fc387448d468c6.zip
Fix unintentional free of the last value when adding a new value to a key.
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/registry/regf.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c
index a7fed42054..a96c7db0ee 100644
--- a/source4/lib/registry/regf.c
+++ b/source4/lib/registry/regf.c
@@ -1791,11 +1791,9 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
break;
}
}
- /* Free data, if any */
- if (!(vk.data_length & 0x80000000)) {
- hbin_free(regf, vk.data_offset);
- }
}
+
+ /* If it's new, create the vk struct, if it's old, free the old data. */
if (old_vk_offset == -1) {
vk.header = "vk";
vk.name_length = strlen(name);
@@ -1806,7 +1804,13 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
vk.data_name = NULL;
vk.flag = 0;
}
+ } else {
+ /* Free data, if any */
+ if (!(vk.data_length & 0x80000000)) {
+ hbin_free(regf, vk.data_offset);
+ }
}
+
/* Set the type and data */
vk.data_length = data.length;
vk.data_type = type;