diff options
author | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2010-03-22 12:00:57 +0100 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2010-03-22 12:26:39 +0100 |
commit | 93472b41dedd8e30be8752c271f2b4bca392176a (patch) | |
tree | 7c2be53bd2b6961b026ab21c8ee5bf5d72586e81 /source4/lib | |
parent | 5f24bfb7b9419d4aac220adc038bd3776fc172e6 (diff) | |
download | samba-93472b41dedd8e30be8752c271f2b4bca392176a.tar.gz samba-93472b41dedd8e30be8752c271f2b4bca392176a.tar.bz2 samba-93472b41dedd8e30be8752c271f2b4bca392176a.zip |
s4:registry - "patchfile_dotreg.c" - fix a memory leak
Here we allocate memory on the "NULL" context through "reg_val_data_string" on
each call of "set_value". So when we have written out the allocated data on the
specified file descriptor we should immediately free this memory! Otherwise we
may end up with a big memory consumption on big registry databases.
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/registry/patchfile_dotreg.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source4/lib/registry/patchfile_dotreg.c b/source4/lib/registry/patchfile_dotreg.c index 3b5708978d..12f2f70774 100644 --- a/source4/lib/registry/patchfile_dotreg.c +++ b/source4/lib/registry/patchfile_dotreg.c @@ -61,10 +61,12 @@ static WERROR reg_dotreg_diff_set_value(void *_data, const char *path, uint32_t value_type, DATA_BLOB value) { struct dotreg_data *data = (struct dotreg_data *)_data; - + char *data_string = reg_val_data_string(NULL, data->iconv_convenience, + value_type, value); + W_ERROR_HAVE_NO_MEMORY(data_string); fdprintf(data->fd, "\"%s\"=%s:%s\n", - value_name, str_regtype(value_type), - reg_val_data_string(NULL, data->iconv_convenience, value_type, value)); + value_name, str_regtype(value_type), data_string); + talloc_free(data_string); return WERR_OK; } |