comparison lwasm/list.c @ 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 e09985968e64
children dc763f806dc4
comparison
equal deleted inserted replaced
272:cfeb196251e4 273:1409debcb1a0
73 } 73 }
74 if (cl -> noexpand_start) 74 if (cl -> noexpand_start)
75 { 75 {
76 obytelen = 0; 76 obytelen = 0;
77 int nc = 0; 77 int nc = 0;
78 for (nl = cl; ; nl = nl -> next) 78 for (nl = cl; nl; nl = nl -> next)
79 { 79 {
80 if (nl -> noexpand_start) 80 if (nl -> noexpand_start)
81 nc++; 81 nc += nl -> noexpand_start;
82 if (nl -> noexpand_end) 82 if (nl -> noexpand_end)
83 nc--; 83 nc -= nl -> noexpand_end;
84 84
85 if (nl -> outputl > 0) 85 if (nl -> outputl > 0)
86 obytelen += nl -> outputl; 86 obytelen += nl -> outputl;
87 if (nl -> warn) 87 if (nl -> warn)
88 { 88 {
105 obytes[nc++] = nl2 -> output[i]; 105 obytes[nc++] = nl2 -> output[i];
106 } 106 }
107 if (nc >= obytelen) 107 if (nc >= obytelen)
108 break; 108 break;
109 } 109 }
110 nl = nl -> next; 110 if (nl)
111 nl = nl -> next;
111 } 112 }
112 else 113 else
113 { 114 {
114 if (cl -> warn) 115 if (cl -> warn)
115 { 116 {