[qfcc] Check for previous errors in vector exprs

Fixes a segfault when one of the expressions used to construct the
vector was the result of an error.
This commit is contained in:
Bill Currie 2020-03-08 15:40:07 +09:00
parent b81d58c795
commit d9d321f65b

View file

@ -659,15 +659,23 @@ new_vector_list (expr_t *e)
case 3:
// quaternion or vector. all expressions must be compatible with
// a float (ie, a scalar)
for (t = e; t; t = t->next)
if (!is_scalar (get_type (t)))
for (t = e; t; t = t->next) {
if (t->type == ex_error) {
return t;
}
if (!is_scalar (get_type (t))) {
return error (t, "invalid type for vector element");
}
}
vec = new_expr ();
vec->type = ex_vector;
vec->e.vector.type = type;
vec->e.vector.list = e;
break;
case 2:
if (e->type == ex_error || e->next->type == ex_error) {
return e;
}
if (is_scalar (get_type (e)) && is_scalar (get_type (e->next))) {
// scalar, scalar
// expand [x, y] to [x, y, 0]