diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-09-26 11:45:14 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:18 -0500 |
commit | 9010d3859eca98d6a28ccf4f461b66a5778be4d5 (patch) | |
tree | f7e282d844c7bd536b861d225874354c31c755f4 /source4 | |
parent | e3880fa759cfa03222262327854fe7bbe585fe01 (diff) | |
download | samba-9010d3859eca98d6a28ccf4f461b66a5778be4d5.tar.gz samba-9010d3859eca98d6a28ccf4f461b66a5778be4d5.tar.bz2 samba-9010d3859eca98d6a28ccf4f461b66a5778be4d5.zip |
r2661: fixed a client side memory leak in the clilist code.
This sort of bug happens quite easily with the new talloc_realloc()
interface. talloc_realloc() now looks like this:
void *talloc_realloc(void *ptr, size_t size);
and if ptr is not NULL then everything is fine. If ptr is NULL then
talloc_realloc() presumes you want to allocate in the NULL context,
which is probably not what is wanted.
For now the solution is to initialise ptr like this:
ptr = talloc(mem_ctx, 0);
so when the realloc happens it has a context to get hold of.
I might change the interface of talloc_realloc() later to prevent this
problem in a more robust manner
(This used to be commit bd813dfb1b08b586dc71f9cec4eb65b35ea808fe)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/libcli/clilist.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source4/libcli/clilist.c b/source4/libcli/clilist.c index 67a2e980ca..529d4f81a3 100644 --- a/source4/libcli/clilist.c +++ b/source4/libcli/clilist.c @@ -117,11 +117,11 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu int ff_dir_handle=0; /* initialize state for search */ - state.dirlist = NULL; state.mem_ctx = talloc_init("smbcli_list_new"); state.dirlist_len = 0; state.total_received = 0; + state.dirlist = talloc(state.mem_ctx, 0); mask = talloc_strdup(state.mem_ctx, Mask); if (tree->session->transport->negotiate.capabilities & CAP_NT_SMBS) { @@ -258,11 +258,11 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu int i; /* initialize state for search */ - state.dirlist = NULL; state.mem_ctx = talloc_init("smbcli_list_old"); state.dirlist_len = 0; state.total_received = 0; - + + state.dirlist = talloc(state.mem_ctx, 0); mask = talloc_strdup(state.mem_ctx, Mask); while (1) { |