# HG changeset patch # User William Astle # Date 1369510546 21600 # Node ID 1409debcb1a098d840aecd834c9a30e4aed7e1fe # Parent cfeb196251e4e9599a43bcaa6e0f72298c1bb1a3 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. diff -r cfeb196251e4 -r 1409debcb1a0 lwasm/list.c --- 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 { diff -r cfeb196251e4 -r 1409debcb1a0 lwasm/pass1.c --- 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)