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

piaojun piaojun at huawei.com
Wed Mar 18 00:44:43 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..84911c4 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");
+		free(filepath);
 		return 0;
 	}
-
+	free(filepath);
 	return 1;
 }

-- 1.8.4.3




More information about the Ocfs2-tools-devel mailing list