shithub: riscv

Download patch

ref: 51950fd7893f962cfe4b39cf504b868dda89f228
parent: df3bb51a1c27e5499e6c80997bfd25db376e3242
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Aug 29 15:58:35 EDT 2023

ms2html: fix crash on macro without newline

when processing an unterminated macro, we would pop
the last input file too early, leading to an invalid
stack access; only pop if we're not the last item on
the stack.

--- a/sys/src/cmd/ms2html.c
+++ b/sys/src/cmd/ms2html.c
@@ -684,13 +684,13 @@
 
 	lastsrc = Input;
 	for(;;) {
-		if(ssp < sstack)
-			return -1;
 		c = Bgetrune(&ssp->in);
 		if(c >= 0){
 			r = c;
 			break;
 		}
+		if(ssp == sstack)
+			return -1;
 		close(ssp->fd);
 		ssp--;
 	}