aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLuis Ontanon <luis.ontanon@gmail.com>2006-03-09 00:50:05 +0000
committerLuis Ontanon <luis.ontanon@gmail.com>2006-03-09 00:50:05 +0000
commit943848cb0233b15f8a9e1eb6d20c078b0c919dc9 (patch)
tree32fec1ec8aaadc1644663e45a7c6d03cf9508dc6 /tools
parent5cd8dbd0283c9883ba845d147908e3a4c5bf2c35 (diff)
Actually fix that leak!
svn path=/trunk/; revision=17540
Diffstat (limited to 'tools')
-rw-r--r--tools/lemon/lemon.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c
index 43e68b146e..db2e3d5e16 100644
--- a/tools/lemon/lemon.c
+++ b/tools/lemon/lemon.c
@@ -2649,16 +2649,17 @@ PRIVATE void tplt_xfer(const char *name, FILE *in, FILE *out, int *lineno)
PRIVATE FILE *tplt_open(struct lemon *lemp)
{
static char templatename[] = "lempar.c";
- char buf[1000];
+ char* buf;
FILE *in;
char *tpltname = NULL;
char *cp;
if (lemp->templatename) {
- tpltname = lemp->templatename;
+ tpltname = strdup(lemp->templatename);
}
else {
cp = strrchr(lemp->filename,'.');
+ buf = malloc(1000);
if( cp ){
sprintf(buf,"%.*s.lt",(int)(cp - lemp->filename),lemp->filename);
}else{
@@ -2668,21 +2669,25 @@ PRIVATE FILE *tplt_open(struct lemon *lemp)
tpltname = buf;
}else{
tpltname = pathsearch(lemp->argv0,templatename,0);
+ free(buf);
}
}
if( tpltname==0 ){
fprintf(stderr,"Can't find the parser driver template file \"%s\".\n",
templatename);
lemp->errorcnt++;
+ free(tpltname);
return 0;
}
in = fopen(tpltname,"r");
+ free(tpltname);
+
if( in==0 ){
fprintf(stderr,"Can't open the template file \"%s\".\n",templatename);
lemp->errorcnt++;
- return 0;
+ return 0;
}
- if (tpltname) free(tpltname);
+
return in;
}