Merge pull request #322 from edward-san/lemon_leak

- Plug some lemon leaks during xlat generation.
This commit is contained in:
coelckers 2015-04-30 14:57:08 +02:00
commit 033712d044

View file

@ -437,7 +437,8 @@ struct acttab {
#define acttab_yylookahead(X,N) ((X)->aAction[N].lookahead)
/* Free all memory associated with the given acttab */
void acttab_free(acttab *p){
void acttab_free(acttab **pp){
acttab *p = *pp;
free( p->aAction );
free( p->aLookahead );
free( p );
@ -2506,12 +2507,14 @@ struct lemon *gp;
ErrorMsg(ps.filename,0,"Can't allocate %d of memory to hold this file.",
filesize+1);
gp->errorcnt++;
fclose(fp);
return;
}
if( fread(filebuf,1,filesize,fp)!=filesize ){
ErrorMsg(ps.filename,0,"Can't read in all %d bytes of this file.",
filesize);
free(filebuf);
fclose(fp);
gp->errorcnt++;
return;
}
@ -3081,9 +3084,11 @@ struct lemon *lemp;
in = fopen(tpltname,"rb");
if( in==0 ){
fprintf(stderr,"Can't open the template file \"%s\".\n",templatename);
free(tpltname);
lemp->errorcnt++;
return 0;
}
free(tpltname);
return in;
}
@ -3942,6 +3947,7 @@ int mhflag; /* Output in makeheaders format if true */
/* Append any addition code the user desires */
tplt_print(out,lemp,lemp->extracode,lemp->extracodeln,&lineno);
acttab_free(&pActtab);
fclose(in);
fclose(out);
return;