From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Price Date: Tue, 02 Jul 2013 13:43:53 +0100 Subject: [Cluster-devel] [PATCH] libgfs2: Fix resource leak in lgfs2_lang_result() In-Reply-To: <1372767937-18869-1-git-send-email-pevans@redhat.com> References: <1372767937-18869-1-git-send-email-pevans@redhat.com> Message-ID: <51D2CB09.6040903@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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); >