From eb9d3841114d3eba1770792f0fb1fc18dc84441e Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 16 May 2004 20:14:59 +0000 Subject: [PATCH] (nstr_comp): Fix handling of condition type mismatch. This bug could trigger oopses in nstr_exec(). (cond_type_mismatch): Clearer diagnostic message. --- src/lib/subs/nstr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/subs/nstr.c b/src/lib/subs/nstr.c index ddab5246..501ba28b 100644 --- a/src/lib/subs/nstr.c +++ b/src/lib/subs/nstr.c @@ -86,6 +86,7 @@ nstr_comp(struct nscstr *np, int len, int type, char *str) /* find operator type, coerce operands */ lft_type = nstr_promote(np->lft.val_type); rgt_type = nstr_promote(np->rgt.val_type); + np->optype = NSC_NOTYPE; if (lft_type == NSC_TYPEID) { if (!nstr_coerce_val(&np->rgt, NSC_TYPEID, str)) np->optype = NSC_TYPEID; @@ -109,6 +110,8 @@ nstr_comp(struct nscstr *np, int len, int type, char *str) && !nstr_coerce_val(&np->rgt, NSC_LONG, str)) np->optype = NSC_LONG; } + if (np->optype == NSC_NOTYPE) + return -1; /* another condition? */ if (*tail == 0) @@ -317,7 +320,7 @@ static int cond_type_mismatch(char *str) { if (str) - pr("%s -- condition type mismatch\n", str); + pr("%s -- condition operand type mismatch\n", str); return -1; }