diff options
author | Chris Maynard <Christopher.Maynard@GTECH.COM> | 2013-07-03 01:47:18 +0000 |
---|---|---|
committer | Chris Maynard <Christopher.Maynard@GTECH.COM> | 2013-07-03 01:47:18 +0000 |
commit | 83b4b73dd1caec6a7f06354f27cadda089c2eaec (patch) | |
tree | 6988aa3017d040f44613d81220062f1bfff511c2 /tools | |
parent | 5d87a8c46171f572568db5a47c093423482e342f (diff) | |
download | wireshark-83b4b73dd1caec6a7f06354f27cadda089c2eaec.tar.gz |
Fix Coverity CID 280323 (Free of array-typed value) by ensuring that tpltname doesn't point to the buf[] stack array before attempting to free it.
#BACKPORT(1.10)
svn path=/trunk/; revision=50335
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lemon/lemon.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index 5e1524f218..cae0889a08 100644 --- a/tools/lemon/lemon.c +++ b/tools/lemon/lemon.c @@ -2235,7 +2235,7 @@ to follow the previous rule."); psp->rhs[psp->nrhs-1] = msp; } msp->nsubsym++; - msp->subsym = (struct symbol **) realloc(msp->subsym, + msp->subsym = (struct symbol **) realloc(msp->subsym, sizeof(struct symbol*)*msp->nsubsym); msp->subsym[msp->nsubsym-1] = Symbol_new(&x[1]); if( safe_islower(x[1]) || safe_islower(msp->subsym[0]->name[0]) ){ @@ -3179,20 +3179,20 @@ PRIVATE FILE *tplt_open(struct lemon *lemp) tpltname = pathsearch(lemp->argv0,templatename,0); } } - if( tpltname==0 ){ + if( tpltname==NULL ){ fprintf(stderr,"Can't find the parser driver template file \"%s\".\n", templatename); lemp->errorcnt++; - free(tpltname); - return 0; + return NULL; } in = fopen(tpltname,"rb"); - free(tpltname); + if( tpltname != buf ) + free(tpltname); if( in==0 ){ fprintf(stderr,"Can't open the template file \"%s\".\n",templatename); lemp->errorcnt++; - return 0; + return NULL; } return in; } |