Skip to content

Commit 9033420

Browse files
committed
the nuinterp_spin array is not zero terminated, check its length
1 parent 4e4cf45 commit 9033420

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

backends/nucode/nuir.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,14 +1065,17 @@ void NuOutputFinish(Flexbuf *fb, NuContext *ctxt)
10651065
int c;
10661066
// find tail of interpreter
10671067
const char *ptr = (char *)sys_nuinterp_spin;
1068+
const char *end_ptr;
10681069
ptr += sys_nuinterp_spin_len-1;
1070+
end_ptr = ptr;
1071+
10691072
// go back to last ^L
10701073
while (ptr && *ptr != '\014') {
10711074
--ptr;
10721075
}
10731076
// output tail
10741077
ptr++;
1075-
for(;;) {
1078+
while (ptr <= end_ptr) {
10761079
c = *ptr++;
10771080
if (c == 0) break;
10781081
if (c == '\001') {

0 commit comments

Comments
 (0)