From 3448cda3df5f0c6896b7ebd5299a6241cb792395 Mon Sep 17 00:00:00 2001 From: marcobaye Date: Tue, 19 May 2020 09:41:54 +0000 Subject: [PATCH] bugfix: unterminated strings could cause crashes git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@174 4df02467-bbd4-4a76-a152-e7ce94205b78 --- src/alu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/alu.c b/src/alu.c index 485c53c..9c8e5ae 100644 --- a/src/alu.c +++ b/src/alu.c @@ -382,8 +382,10 @@ static void parse_quoted_character(char closing_quote) // FIXME - this will fail with backslash escaping! // read character to parse - make sure not at end of statement - if (GetQuotedByte() == CHAR_EOS) + if (GetQuotedByte() == CHAR_EOS) { + alu_state = STATE_ERROR; return; + } // on empty string, complain if (GotByte == closing_quote) { @@ -1699,11 +1701,15 @@ static void try_to_reduce_stacks(struct expression *expression) #define ARG_NOW (arg_stack[arg_sp - 1]) switch (previous_op->group) { case OPGROUP_MONADIC: // monadic operators + if (arg_sp < 1) + Bug_found("ArgStackEmpty", arg_sp); // FIXME - add to docs! ARG_NOW.type->handle_monadic_operator(&ARG_NOW, previous_op); // operation was something other than parentheses expression->is_parenthesized = FALSE; break; case OPGROUP_DYADIC: // dyadic operators + if (arg_sp < 2) + Bug_found("NotEnoughArgs", arg_sp); // FIXME - add to docs! ARG_PREV.type->handle_dyadic_operator(&ARG_PREV, previous_op, &ARG_NOW); // decrement argument stack pointer because dyadic operator merged two arguments into one --arg_sp;