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

piaojun piaojun at huawei.com
Sun Mar 29 01:24:50 PDT 2015


Hi Mark,

	The whitespace errors are all fixed and there are no obvious style
problems in the patch now. Thanks for reviewing!

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

在 2015/3/18 15:44, piaojun 写道:
> 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
> 
> 
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel
> 
> 




More information about the Ocfs2-tools-devel mailing list