diff options
Diffstat (limited to 'tools/lemon/lemon.c')
-rw-r--r-- | tools/lemon/lemon.c | 8 |
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; } |