Related articles |
---|
Byacc 1.9 - array out of bound in byacc (not generated) code. dborkov@nyx.nyx.net (1999-01-27) |
From: | dborkov@nyx.nyx.net (D.Borkov) |
Newsgroups: | comp.compilers |
Date: | 27 Jan 1999 12:13:48 -0500 |
Organization: | Nyx Net, Free Internet access (www.nyx.net) |
Keywords: | yacc, errors |
I believe there is a bug in byacc v1.9 code - not generated code.
In the function pack_vector() in the file output.c
approximately around the line 569.
Here is the old and the new code illustrating the problem.
OLD CODE:
+++ if (loc >= maxtable)
+++ {
+++ if (loc >= MAXTABLE)
CORRECT (I believe) CODE:
--- if (loc >= maxtable - 1)
--- {
--- if (loc >= MAXTABLE - 1)
The problem is that in the old code the "check[]"
array could be completely filled in the statement
check[loc] = from[k];
when the index "loc" reaches "(maxtable-1)".
Then there would be no space left for at least one "(-1)" at the end
of the "check[]" array and the index "lowzero" could end up pointing
outside proper bounds in the following loop near the end of the same
function:
while (check[lowzero] != -1)
++lowzero;
I would appreciate someone checking this fix, and, if correct, adding
it to a publicly available archive since I have no means of doing
so. Mailing me the article would be nice too, since I would hate to
miss the consequent postings :-).
Regards,
Drazen <d.bork@altavista.net>
Return to the
comp.compilers page.
Search the
comp.compilers archives again.