From 9010d3859eca98d6a28ccf4f461b66a5778be4d5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 26 Sep 2004 11:45:14 +0000 Subject: 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) --- source4/libcli/clilist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli') 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) { -- cgit