From b4dced09bbfc13bdd3ae50936bc5d8b4b883edf3 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Thu, 31 May 2012 15:43:14 -0700 Subject: [PATCH] Fix bug #8970 - Possible memory leaks in the samba master process. Signed-off-by: Jeremy Allison --- source3/lib/debug.c | 13 ++++++++----- source3/param/loadparm.c | 6 +++++- source3/smbd/server.c | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 80b8310..05e9eee 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -657,9 +657,11 @@ bool reopen_logs( void ) SAFE_FREE(fname); fname = SMB_STRDUP(logfname); if (!fname) { + TALLOC_FREE(logfname); return false; } } + TALLOC_FREE(logfname); } debugf = fname; @@ -1028,6 +1030,8 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func) */ if( lp_timestamp_logs() || lp_debug_prefix_timestamp() || !(lp_loaded()) ) { char header_str[200]; + char *curtime = current_timestring(talloc_tos(), + lp_debug_hires_timestamp()); header_str[0] = '\0'; @@ -1050,19 +1054,18 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func) ", class=%s", default_classname_table[cls]); } - + /* Print it all out at once to prevent split syslog output. */ if( lp_debug_prefix_timestamp() ) { (void)Debug1( "[%s, %2d%s] ", - current_timestring(talloc_tos(), - lp_debug_hires_timestamp()), + curtime, level, header_str); } else { (void)Debug1( "[%s, %2d%s] %s(%s)\n", - current_timestring(talloc_tos(), - lp_debug_hires_timestamp()), + curtime, level, header_str, location, func ); } + TALLOC_FREE(curtime); } errno = old_errno; diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 28ffc08..5800bec 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -9283,7 +9283,11 @@ bool lp_load_ex(const char *pszFname, } } - lp_add_auto_services(lp_auto_services()); + { + char *serv = lp_auto_services(); + lp_add_auto_services(serv); + TALLOC_FREE(serv); + } if (add_ipc) { /* When 'restrict anonymous = 2' guest connections to ipc$ diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 201e301..63a9869 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -804,6 +804,7 @@ bool reload_services(bool test) set_dyn_CONFIGFILE(fname); test = False; } + TALLOC_FREE(fname); } reopen_logs(); -- 1.7.7.3