aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
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;
}