[CRIU] [PATCH 3/8] cr-dump: don't forget to free mme.vmas

Dmitry Safonov dsafonov at virtuozzo.com
Fri Jul 15 12:28:42 PDT 2016


...
cr-dump.c:515:9: warning: Potential leak of memory pointed to by 'mme.vmas'
        return ret;
               ^~~

Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/cr-dump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 2c0aacbf22f9..953ecc46aa18 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -451,7 +451,7 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat,
 	mme.n_vmas = vma_area_list->nr;
 	mme.vmas = xmalloc(mme.n_vmas * sizeof(VmaEntry *));
 	if (!mme.vmas)
-		goto err;
+		return -1;
 
 	list_for_each_entry(vma_area, &vma_area_list->h, list) {
 		VmaEntry *vma = vma_area->e;
@@ -512,6 +512,7 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat,
 	xfree(mme.mm_saved_auxv);
 	free_aios(&mme);
 err:
+	xfree(mme.vmas);
 	return ret;
 }
 
-- 
2.9.0



More information about the CRIU mailing list