From cb6697da8004116a996bf8fefb83c689dc039da9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 31 May 2012 16:25:52 -0700 Subject: [PATCH] Forward port of Richard Sharpe's fix for bug #8970 - Possible memory leaks in the samba master process. --- source3/nmbd/nmbd.c | 3 ++- source3/param/loadparm.c | 6 +++++- source3/printing/load.c | 7 ++++++- source3/smbd/server_reload.c | 1 + source3/winbindd/winbindd.c | 3 ++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 986c575..0172e08 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -365,11 +365,12 @@ static bool reload_nmbd_services(bool test) set_remote_machine_name("nmbd", False); if ( lp_loaded() ) { - const char *fname = lp_configfile(); + char *fname = lp_configfile(); if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); test = False; } + TALLOC_FREE(fname); } if ( test && !lp_file_list_changed() ) diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 6ad2452..195a6b3 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -9647,7 +9647,11 @@ static 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/printing/load.c b/source3/printing/load.c index 5acc258..829c3e3 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -30,6 +30,7 @@ static void add_auto_printers(void) int pnum = lp_servicenumber(PRINTERS_NAME); char *str; char *saveptr; + char *auto_serv = NULL; if (pnum < 0) if (process_registry_service(PRINTERS_NAME)) @@ -38,8 +39,12 @@ static void add_auto_printers(void) if (pnum < 0) return; - if ((str = SMB_STRDUP(lp_auto_services())) == NULL) + auto_serv = lp_auto_services(); + str = SMB_STRDUP(auto_serv); + TALLOC_FREE(auto_serv); + if (str == NULL) { return; + } for (p = strtok_r(str, LIST_SEP, &saveptr); p; p = strtok_r(NULL, LIST_SEP, &saveptr)) { diff --git a/source3/smbd/server_reload.c b/source3/smbd/server_reload.c index 6e0ab39..fd6dc1a 100644 --- a/source3/smbd/server_reload.c +++ b/source3/smbd/server_reload.c @@ -127,6 +127,7 @@ bool reload_services(struct messaging_context *msg_ctx, int smb_sock, set_dyn_CONFIGFILE(fname); test = False; } + TALLOC_FREE(fname); } reopen_logs(); diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 110f034..f80949d 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -65,11 +65,12 @@ static bool reload_services_file(const char *lfile) bool ret; if (lp_loaded()) { - const char *fname = lp_configfile(); + char *fname = lp_configfile(); if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); } + TALLOC_FREE(fname); } /* if this is a child, restore the logfile to the special -- 1.7.7.3