cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] libgfs2: Fix resource leak in lgfs2_lang_result()
@ 2013-07-02 12:25 Paul Evans
  2013-07-02 12:43 ` Andrew Price
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Evans @ 2013-07-02 12:25 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Spotted by coverity: Resource leak, variable "result" going out of scope
and leaking the storage it points to.

Variable "result" is now free'd before returning.

Signed-off-by: Paul Evans <pevans@redhat.com>
---
 gfs2/libgfs2/lang.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index 28805b5..3cc5f29 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -421,6 +421,7 @@ static struct lgfs2_lang_result *ast_interp_get(struct lgfs2_lang_state *state,
 	} else if (ast->ast_right->ast_right->ast_type == AST_KW_STATE) {
 		result->lr_blocknr = ast_lookup_block_num(ast->ast_right, sbd);
 		if (result->lr_blocknr == 0) {
+                        free(result);
 			return NULL;
 		}
 		result->lr_state = ast_get_bitstate(result->lr_blocknr, sbd);
-- 
1.7.11.7



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Cluster-devel] [PATCH] libgfs2: Fix resource leak in lgfs2_lang_result()
  2013-07-02 12:25 [Cluster-devel] [PATCH] libgfs2: Fix resource leak in lgfs2_lang_result() Paul Evans
@ 2013-07-02 12:43 ` Andrew Price
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Price @ 2013-07-02 12:43 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi Paul,

On 02/07/13 13:25, Paul Evans wrote:
> Spotted by coverity: Resource leak, variable "result" going out of scope
> and leaking the storage it points to.
>
> Variable "result" is now free'd before returning.
>
> Signed-off-by: Paul Evans <pevans@redhat.com>

Looks good to me.

> ---
>   gfs2/libgfs2/lang.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
> index 28805b5..3cc5f29 100644
> --- a/gfs2/libgfs2/lang.c
> +++ b/gfs2/libgfs2/lang.c
> @@ -421,6 +421,7 @@ static struct lgfs2_lang_result *ast_interp_get(struct lgfs2_lang_state *state,
>   	} else if (ast->ast_right->ast_right->ast_type == AST_KW_STATE) {
>   		result->lr_blocknr = ast_lookup_block_num(ast->ast_right, sbd);
>   		if (result->lr_blocknr == 0) {
> +                        free(result);

Just a style nit: please use tabs for indentation and spaces for alignment.

Cheers,
Andy

>   			return NULL;
>   		}
>   		result->lr_state = ast_get_bitstate(result->lr_blocknr, sbd);
>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-02 12:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-02 12:25 [Cluster-devel] [PATCH] libgfs2: Fix resource leak in lgfs2_lang_result() Paul Evans
2013-07-02 12:43 ` Andrew Price

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).