diff options
author | Volker Lendecke <vlendec@samba.org> | 2007-04-28 18:16:33 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:19:45 -0500 |
commit | e26dee48f079f429690584aa2666f498e08e6810 (patch) | |
tree | 8dc7f67920ddde9cde1e9e7baa0aa3dd5d189170 /source3/smbd | |
parent | a01c1968b53503594dad9c8d8817a6941a4eaeea (diff) | |
download | samba-e26dee48f079f429690584aa2666f498e08e6810.tar.gz samba-e26dee48f079f429690584aa2666f498e08e6810.tar.bz2 samba-e26dee48f079f429690584aa2666f498e08e6810.zip |
r22561: Fix a memleak in lanman.c: Nobody would free the session_list.
Volker
(This used to be commit 5d428400f77399b7fc30fb2a0fb10f0c74b96458)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/lanman.c | 2 | ||||
-rw-r--r-- | source3/smbd/session.c | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index cd2750d759..05b1e812b2 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -4213,7 +4213,7 @@ static BOOL api_RNetSessionEnum(connection_struct *conn, uint16 vuid, return False; } - num_sessions = list_sessions(&session_list); + num_sessions = list_sessions(tmp_talloc_ctx(), &session_list); if (mdrcnt > 0) { *rdata = SMB_REALLOC_LIMIT(*rdata,mdrcnt); diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 05b1026f41..30ade8aedf 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -218,6 +218,7 @@ BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), ********************************************************************/ struct session_list { + TALLOC_CTX *mem_ctx; int count; struct sessionid *sessions; }; @@ -230,7 +231,9 @@ static int gather_sessioninfo(TDB_CONTEXT *stdb, TDB_DATA kbuf, TDB_DATA dbuf, v i = sesslist->count; - sesslist->sessions = SMB_REALLOC_ARRAY(sesslist->sessions, struct sessionid, i+1); + sesslist->sessions = TALLOC_REALLOC_ARRAY( + sesslist->mem_ctx, sesslist->sessions, struct sessionid, i+1); + if (!sesslist->sessions) { sesslist->count = 0; return -1; @@ -248,10 +251,11 @@ static int gather_sessioninfo(TDB_CONTEXT *stdb, TDB_DATA kbuf, TDB_DATA dbuf, v /******************************************************************** ********************************************************************/ -int list_sessions(struct sessionid **session_list) +int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list) { struct session_list sesslist; + sesslist.mem_ctx = mem_ctx; sesslist.count = 0; sesslist.sessions = NULL; |