commit 511b3aa71fae5d4e941fe3159828c84c7f74ba51 from: Omar Polo date: Sat Aug 07 09:37:56 2021 UTC guard against assigning variables to void values commit - c4d04e1c300d4ff855a18779e7de362a7987c46d commit + 511b3aa71fae5d4e941fe3159828c84c7f74ba51 blob - cb8c623fc00b991d06136a34833c8c3ade724e71 blob + 8e604fe1fe17883283a912f4595e5c31887f54a6 --- script.c +++ script.c @@ -236,11 +236,20 @@ setvar(char *sym, struct op *op) { struct binding *b; struct env *e; - int ret; + int ret, height; + height = stackh; if ((ret = eval(op)) != EVAL_OK) return ret; + if (stackh != height + 1) { + before_printing(); + printf("trying to assign to `%s' a void value: ", sym); + pp_op(op); + printf("\n"); + return EVAL_ERR; + } + b = xcalloc(1, sizeof(*b)); b->name = sym; popv(&b->val);