[sheepdog] [PATCH] sheep, recovery: fix memory leak

Liu Yuan namei.unix at gmail.com
Tue Jun 5 13:29:45 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

Oops, after replying the patch, I found this memory leak bug.
-------------------------------------------------------- >8

We should also free prio_oids

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/recovery.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sheep/recovery.c b/sheep/recovery.c
index d3ce53c..9b715ea 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -403,10 +403,10 @@ static inline void finish_schedule_oids(struct recovery_work *rw)
 	dprintf("nr_recovered %d, nr_prio_oids %d, count %d, new %d\n",
 		nr_recovered, rw->nr_prio_oids, rw->count, new_idx);
 
-	free(rw->prio_oids);
 	free(rw->oids);
 	rw->oids = new_oids;
 done:
+	free(rw->prio_oids);
 	rw->prio_oids = NULL;
 	rw->nr_prio_oids = 0;
 }
-- 
1.7.10.2




More information about the sheepdog mailing list