From: Alain Spineux Date: Fri, 26 Apr 2019 13:20:34 +0000 (+0200) Subject: fix memory leak in DIR for copy-job X-Git-Tag: Release-9.4.3~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c5a4feb2b4e088917b8a6e14a3e250fc6860ca1;p=thirdparty%2Fbacula.git fix memory leak in DIR for copy-job - 127.0.0.1-dir: smartall.c:409-0 Orphaned buffer: 127.0.0.1-dir 24 bytes at 7fdd44010fd8 from mac_sql.c:714 - dlist::remove() don't free the item that is removed, you have to delete it yourself 127.0.0.1-dir: mac_sql.c:527-0 regex-sel-pattern=RestartJob 127.0.0.1-dir: mac_sql.c:530-0 get name query1=SELECT DISTINCT Job.Name from Job,Pool WHERE Pool.Name='Default' AND Job.PoolId=Pool.PoolId 127.0.0.1-dir: mac_sql.c:537-0 query1 returned 2 names 127.0.0.1-dir: mac_sql.c:561-0 get name Item=ContinuousJob 7fdd44010fd8 7fdd440276d8 127.0.0.1-dir: mac_sql.c:557-0 Remove item ContinuousJob 127.0.0.1-dir: mac_sql.c:561-0 get name Item=RestartJob 7fdd44011118 7fdd4404a478 127.0.0.1-dir: mac_sql.c:589-0 Got Job: RestartJob 127.0.0.1-dir: mac_sql.c:591-0 get id from name query2=SELECT DISTINCT Job.JobId,Job.StartTime FROM Job,Pool WHERE Job.Name='RestartJob' AND Pool.Name='Default' AND Job.PoolId=Pool.PoolId ORDER by Job.StartTime 127.0.0.1-dir: mac_sql.c:604-0 Count=2 Jobids=1,4 127.0.0.1-dir: mac_sql.c:606-0 Free 7fdd44011118 7fdd4404a478 RestartJob 127.0.0.1-dir: dlist.c:327-0 Destroy head=7fdd44011118 127.0.0.1-dir: dlist.c:330-0 Destroy free n=7fdd44011118 ni=0 127.0.0.1-dir: smartall.c:409-0 Orphaned buffer: 127.0.0.1-dir 24 bytes at 7fdd44010fd8 from mac_sql.c:714 --- diff --git a/bacula/src/dird/mac_sql.c b/bacula/src/dird/mac_sql.c index 40bbf9179..cb4c732e1 100644 --- a/bacula/src/dird/mac_sql.c +++ b/bacula/src/dird/mac_sql.c @@ -559,6 +559,7 @@ static bool regex_find_jobids(JCR *jcr, idpkt *ids, const char *query1, Dmsg1(dbglevel, "Remove item %s\n", last_item->item); free(last_item->item); item_chain->remove(last_item); + free(last_item); } Dmsg1(dbglevel, "get name Item=%s\n", item->item); rc = regexec(&preg, item->item, nmatch, pmatch, 0); @@ -572,6 +573,7 @@ static bool regex_find_jobids(JCR *jcr, idpkt *ids, const char *query1, Dmsg1(dbglevel, "Remove item %s\n", last_item->item); free(last_item->item); item_chain->remove(last_item); + free(last_item); } regfree(&preg); }