[Ocfs2-tools-devel] [PATCH 7/8 V2] Fix a memory leak problem in o2image.c

piaojun piaojun at huawei.com
Sun Mar 29 18:53:19 PDT 2015


In prompt_image_creation(), 'filepath' should be freed before the function
returns.

Signed-off-by: Jun Piao <piaojun at huawei.com>
Reviewed-by: Alex Chen <alex.chen at huawei.com>

---
 o2image/o2image.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/o2image/o2image.c b/o2image/o2image.c
index 465e7fe..8fe942c 100644
--- a/o2image/o2image.c
+++ b/o2image/o2image.c
@@ -674,9 +674,10 @@ static int prompt_image_creation(ocfs2_filesys *ofs, int rawflg, char *filename)
 		img_size/1024, free_spc/1024);
 	if (toupper(getchar()) != 'Y') {
 		fprintf(stdout, "Aborting image creation.\n");
+		ocfs2_free(&filepath);
 		return 0;
 	}
-
+	ocfs2_free(&filepath);
 	return 1;
 }

-- 1.8.4.3




More information about the Ocfs2-tools-devel mailing list