From 4b72993e746bc654178ba80b66ed6a1f854210e1 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 15 Jul 2024 14:36:57 -0400 Subject: bas.c: warn and return from walk_code() if the program ends in the middle of a line. --- bas.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'bas.c') diff --git a/bas.c b/bas.c index ddc424f..94ba310 100644 --- a/bas.c +++ b/bas.c @@ -316,6 +316,10 @@ void walk_code(unsigned int startlineno, unsigned int endlineno) { lineno = tmpno; offset = program[linepos + 2]; nextpos = linepos + offset; + if(nextpos > filelen) { + fprintf(stderr, "Warning: program truncated in the middle of line %d.\n", lineno); + return; + } end = nextpos; pos = linepos; -- cgit v1.2.3