gs: fix missing type check in ztype (thanks jsmoody)
to reproduce: gs <<. null [[][][][][][][][][][][][][][][]] .type .
This commit is contained in:
parent
e55778d67e
commit
c9a1045d49
1 changed files with 13 additions and 8 deletions
|
@ -77,14 +77,15 @@ ztype(i_ctx_t *i_ctx_p)
|
|||
/* Must be either a stack underflow or a t_[a]struct. */
|
||||
check_op(2);
|
||||
{ /* Get the type name from the structure. */
|
||||
const char *sname =
|
||||
gs_struct_type_name_string(gs_object_type(imemory,
|
||||
op[-1].value.pstruct));
|
||||
int code = name_ref(imemory, (const byte *)sname, strlen(sname),
|
||||
(ref *) (op - 1), 0);
|
||||
|
||||
if (code < 0)
|
||||
return code;
|
||||
if ((r_has_type(&op[-1], t_struct) || r_has_type(&op[-1], t_astruct))
|
||||
&& op[-1].value.pstruct != 0x00) {
|
||||
const char *sname =
|
||||
gs_struct_type_name_string(gs_object_type(imemory, op[-1].value.pstruct));
|
||||
code = name_ref(imemory, (const byte *)sname, strlen(sname), (ref *) (op - 1), 0);
|
||||
if (code < 0)
|
||||
return code;
|
||||
} else
|
||||
return_error(e_stackunderflow);
|
||||
}
|
||||
r_set_attrs(op - 1, a_executable);
|
||||
} else {
|
||||
|
@ -350,6 +351,8 @@ zcvrs(i_ctx_t *i_ctx_p)
|
|||
pop(2);
|
||||
return 0;
|
||||
}
|
||||
case t__invalid:
|
||||
return_error(e_stackunderflow);
|
||||
default:
|
||||
return_op_typecheck(op - 2);
|
||||
}
|
||||
|
@ -371,6 +374,8 @@ zcvrs(i_ctx_t *i_ctx_p)
|
|||
return_error(e_rangecheck);
|
||||
ival = (ulong) (long)fval;
|
||||
} break;
|
||||
case t__invalid:
|
||||
return_error(e_stackunderflow);
|
||||
default:
|
||||
return_op_typecheck(op - 2);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue