From 3c5a4feb2b4e088917b8a6e14a3e250fc6860ca1 Mon Sep 17 00:00:00 2001 From: Alain Spineux Date: Fri, 26 Apr 2019 15:20:34 +0200 Subject: [PATCH] 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 --- bacula/src/dird/mac_sql.c | 2 ++ 1 file changed, 2 insertions(+) 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); } -- 2.47.3