aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lemon
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2018-04-01 22:02:42 +0200
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2018-04-05 18:51:57 +0000
commitc95e18333c8baf130517534e83fd09024f107c06 (patch)
tree985a295d89f737c3778c381903652a8d4d696e63 /tools/lemon
parent02ef13fac7309244436100853d78bc03b21f4a42 (diff)
lemon: remove leak in tplt_open().
Change-Id: I6a13c89e27797f8c8d1e187aef8923b9df0c8ee4 Reviewed-on: https://code.wireshark.org/review/26706 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'tools/lemon')
-rw-r--r--tools/lemon/lemon.c8
1 files changed, 8 insertions, 0 deletions
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;
}