From c95e18333c8baf130517534e83fd09024f107c06 Mon Sep 17 00:00:00 2001 From: Dario Lombardo Date: Sun, 1 Apr 2018 22:02:42 +0200 Subject: lemon: remove leak in tplt_open(). Change-Id: I6a13c89e27797f8c8d1e187aef8923b9df0c8ee4 Reviewed-on: https://code.wireshark.org/review/26706 Petri-Dish: Dario Lombardo Tested-by: Petri Dish Buildbot Reviewed-by: Alexis La Goutte --- tools/lemon/lemon.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tools/lemon') diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index 64e4179f28..4673e1d061 100644 --- a/tools/lemon/lemon.c +++ b/tools/lemon/lemon.c @@ -3515,6 +3515,7 @@ PRIVATE FILE *tplt_open(struct lemon *lemp) char buf[1000]; FILE *in; char *tpltname; + int tpltname_allocd = LEMON_FALSE; char *cp; /* first, see if user specified a template filename on the command line. */ @@ -3547,20 +3548,27 @@ PRIVATE FILE *tplt_open(struct lemon *lemp) tpltname = templatename; }else{ tpltname = pathsearch(lemp->argv0,templatename,0); + tpltname_allocd = LEMON_TRUE; } if( tpltname==0 ){ fprintf(stderr,"Can't find the parser driver template file \"%s\".\n", templatename); lemp->errorcnt++; + if (tpltname_allocd) + free(tpltname); return 0; } in = fopen(tpltname,"rb"); if( in==0 ){ fprintf(stderr,"Can't open the template file \"%s\".\n",templatename); lemp->errorcnt++; + if (tpltname_allocd) + free(tpltname); return 0; } + if (tpltname_allocd) + free(tpltname); return in; } -- cgit v1.2.3