iverilog/ivlpp
nog 13e07d6b7c Avoid stepping on free'd memory during recursive macro expansion
During macro expansion (with arguments), there is one global buffer
(exp_buf) that keeps getting reallocated to fit all the macro's text
that's currently being expanded.  The problem with this scheme is that if
a macro with arguments needs to be expanded from the macro text of another
macro with arguments, it may happen that the second expansion forces
the above exp_buf buffer to be reallocated.  Which is fine until the
previous macro processing resumes where (struct include_stack_t *)->str
now points to uninitialised memory.  Basically, the code that can trigger
such behaviour is as follows:

`define FOO(a)	(a+3)
`define BAR(b)	(`FOO(b)+2)

`BAR(x)

Ofcourse, you need to get lucky to get the exp_buf to be realloced at the
right point, but it's possible.

I don't see the advantage in keeping all the expanding macro's text
together, so my solution is to simply allocate a new buffer and pass it
as (struct include_stack_t *)->str to the flex parsing function and free
it at the end.
2009-06-08 08:51:31 -07:00
..
Makefile.in Update mkinstalldirs to handle paths with spaces. 2009-02-04 08:44:22 -08:00
globals.h Make the addition of the local directory optional (include path). 2009-02-05 08:37:33 -08:00
ivlpp.txt Spelling fixes 2008-01-29 20:24:24 -08:00
lexor.lex Avoid stepping on free'd memory during recursive macro expansion 2009-06-08 08:51:31 -07:00
main.c Add compiler support for `celldefine, vpiCellInstance 2009-05-24 10:21:37 -07:00