Mercurial > hg > index.cgi
changeset 273:1409debcb1a0
Fix crash on listing when nested noexpand macros are used
Macros flagged noexpand were causing a segfault during listing. The problem
was incorrect accounting for nesting levels for noexpand macros causing the
listing handler to fall off the end of the program in certain circumstances
and in other circumstances it would fail to suppress expansion. Both the
segfault in the case of misbehaviour and the misbhaviour itself are
corrected with this update.
If you do not use nested noexpand macros, this bug has no effect.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sat, 25 May 2013 13:35:46 -0600 |
parents | cfeb196251e4 |
children | d9d02dbf76a6 |
files | lwasm/list.c lwasm/pass1.c |
diffstat | 2 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lwasm/list.c Sat Apr 20 11:00:11 2013 -0600 +++ b/lwasm/list.c Sat May 25 13:35:46 2013 -0600 @@ -75,12 +75,12 @@ { obytelen = 0; int nc = 0; - for (nl = cl; ; nl = nl -> next) + for (nl = cl; nl; nl = nl -> next) { if (nl -> noexpand_start) - nc++; + nc += nl -> noexpand_start; if (nl -> noexpand_end) - nc--; + nc -= nl -> noexpand_end; if (nl -> outputl > 0) obytelen += nl -> outputl; @@ -107,7 +107,8 @@ if (nc >= obytelen) break; } - nl = nl -> next; + if (nl) + nl = nl -> next; } else {
--- a/lwasm/pass1.c Sat Apr 20 11:00:11 2013 -0600 +++ b/lwasm/pass1.c Sat May 25 13:35:46 2013 -0600 @@ -88,11 +88,11 @@ } else if (!strcmp(line + 2, "SETNOEXPANDSTART")) { - as -> line_tail -> noexpand_start = 1; + as -> line_tail -> noexpand_start += 1; } else if (!strcmp(line + 2, "SETNOEXPANDEND")) { - as -> line_tail -> noexpand_end = 1; + as -> line_tail -> noexpand_end += 1; } lw_free(line); if (lc == 0)