]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
fix memory leak in DIR for copy-job
authorAlain Spineux <alain@baculasystems.com>
Fri, 26 Apr 2019 13:20:34 +0000 (15:20 +0200)
committerKern Sibbald <kern@sibbald.com>
Thu, 2 May 2019 13:28:21 +0000 (15:28 +0200)
- 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

index 40bbf9179a68a8818b29cb761d3089833bf06472..cb4c732e19253efd6dfdc7be8b0c53cad0e59576 100644 (file)
@@ -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);
    }