diff options
author | drh <drh@noemail.net> | 2020-09-20 12:10:28 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2020-09-20 12:10:28 +0000 |
commit | 79d9af960b39c02be348b68b14f4a8736137a0e3 (patch) | |
tree | e24d09464ce9a83c5d95235f19d5abc590c9ca60 /tool/lemon.c | |
parent | 68cffa65fba2f59d91e1da582e2a0b0fa7a4211a (diff) | |
download | sqlite-79d9af960b39c02be348b68b14f4a8736137a0e3.tar.gz sqlite-79d9af960b39c02be348b68b14f4a8736137a0e3.zip |
Attempt to silence harmless static analyzer warnings in Lemon and in the
Lemon-generated parser.
FossilOrigin-Name: de8ce22a46c90afa5475cd24c28b7a82b26410dc72d662af2f9d9e5e528e0eec
Diffstat (limited to 'tool/lemon.c')
-rw-r--r-- | tool/lemon.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tool/lemon.c b/tool/lemon.c index 82531362e..a2796c94f 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -1598,7 +1598,7 @@ static struct rule *Rule_sort(struct rule *rp){ while( rp ){ pNext = rp->next; rp->next = 0; - for(i=0; i<sizeof(x)/sizeof(x[0]) && x[i]; i++){ + for(i=0; i<sizeof(x)/sizeof(x[0])-1 && x[i]; i++){ rp = Rule_merge(x[i], rp); x[i] = 0; } @@ -3518,7 +3518,7 @@ PRIVATE char *pathsearch(char *argv0, char *name, int modemask) { const char *pathlist; char *pathbufptr; - char *pathbuf; + char *pathbuf = 0; char *path,*cp; char c; @@ -3552,8 +3552,8 @@ PRIVATE char *pathsearch(char *argv0, char *name, int modemask) else pathbuf = &cp[1]; if( access(path,modemask)==0 ) break; } - free(pathbufptr); } + free(pathbufptr); } return path; } @@ -3637,6 +3637,7 @@ PRIVATE FILE *tplt_open(struct lemon *lemp) char buf[1000]; FILE *in; char *tpltname; + char *toFree = 0; char *cp; /* first, see if user specified a template filename on the command line. */ @@ -3668,7 +3669,7 @@ PRIVATE FILE *tplt_open(struct lemon *lemp) }else if( access(templatename,004)==0 ){ tpltname = templatename; }else{ - tpltname = pathsearch(lemp->argv0,templatename,0); + toFree = tpltname = pathsearch(lemp->argv0,templatename,0); } if( tpltname==0 ){ fprintf(stderr,"Can't find the parser driver template file \"%s\".\n", @@ -3678,10 +3679,10 @@ PRIVATE FILE *tplt_open(struct lemon *lemp) } in = fopen(tpltname,"rb"); if( in==0 ){ - fprintf(stderr,"Can't open the template file \"%s\".\n",templatename); + fprintf(stderr,"Can't open the template file \"%s\".\n",tpltname); lemp->errorcnt++; - return 0; } + free(toFree); return in; } |