aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2016-01-28 18:26:20 +0100
committerMichael Mann <mmann78@netscape.net>2016-01-31 13:27:25 +0000
commit2bf715dcc23cb3e8595e2726a9ae419389eeb05e (patch)
tree6b6de1ff979f367bc88be4f32fa78295702ba60e /tools
parent4fc7423da06a19fe99867a68d2d3fe2de697d29b (diff)
lemon: fix leak.
Found by clang's ccc-analyzer. Change-Id: I04eaad73486a43a77c4f08cf519bbfe7d2d8c838 Reviewed-on: https://code.wireshark.org/review/13581 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/lemon/lemon.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c
index d9480ee1f3..51eb336870 100644
--- a/tools/lemon/lemon.c
+++ b/tools/lemon/lemon.c
@@ -3347,6 +3347,7 @@ PRIVATE FILE *tplt_open(struct lemon *lemp)
char buf[1000];
FILE *in;
char *tpltname;
+ char *tpltname_alloc = NULL;
char *cp;
/* first, see if user specified a template filename on the command line. */
@@ -3378,7 +3379,8 @@ PRIVATE FILE *tplt_open(struct lemon *lemp)
}else if( access(templatename,004)==0 ){
tpltname = templatename;
}else{
- tpltname = pathsearch(lemp->argv0,templatename,0);
+ tpltname_alloc = pathsearch(lemp->argv0,templatename,0);
+ tpltname = tpltname_alloc;
}
if( tpltname==0 ){
fprintf(stderr,"Can't find the parser driver template file \"%s\".\n",
@@ -3390,7 +3392,9 @@ PRIVATE FILE *tplt_open(struct lemon *lemp)
if( in==0 ){
fprintf(stderr,"Can't open the template file \"%s\".\n",templatename);
lemp->errorcnt++;
- return 0;
+ }
+ if (tpltname_alloc) {
+ free(tpltname_alloc);
}
return in;
}