svn commit: samba r2661 - in branches/SAMBA_4_0/source/libcli: .
tridge at samba.org
tridge at samba.org
Sun Sep 26 11:45:15 GMT 2004
Author: tridge
Date: 2004-09-26 11:45:14 +0000 (Sun, 26 Sep 2004)
New Revision: 2661
WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source/libcli&rev=2661&nolog=1
Log:
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
Modified:
branches/SAMBA_4_0/source/libcli/clilist.c
Changeset:
Modified: branches/SAMBA_4_0/source/libcli/clilist.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/clilist.c 2004-09-26 11:30:20 UTC (rev 2660)
+++ branches/SAMBA_4_0/source/libcli/clilist.c 2004-09-26 11:45:14 UTC (rev 2661)
@@ -117,11 +117,11 @@
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 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) {
More information about the samba-cvs
mailing list