From 8b1a5b7dbf993908f24c1a0a1ddebbf2b96c70dd Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 14 Jun 2020 11:18:15 +0300 Subject: Check for FUNCTAB and SYMTAB as destination in builtin functions. --- builtin.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'builtin.c') diff --git a/builtin.c b/builtin.c index 7ef2acd8..9b5609fa 100644 --- a/builtin.c +++ b/builtin.c @@ -2678,6 +2678,8 @@ do_match(int nargs) dest = POP_PARAM(); if (dest->type != Node_var_array) fatal(_("match: third argument is not an array")); + check_symtab_functab(dest, "match", + _("%s: cannot use %s as third argument")); assoc_clear(dest); } tre = POP(); @@ -4328,3 +4330,15 @@ fmt: } return buf; } + + +/* check_symtab_functab --- check if dest is SYMTAB or FUNCTAB, fatal if so */ + +void +check_symtab_functab(NODE *dest, const char *fname, const char *msg) +{ + if (dest == symbol_table) + fatal(msg, fname, "SYMTAB"); + else if (dest == func_table) + fatal(msg, fname, "FUNCTAB"); +} -- cgit v1.2.3