Fix the bug where length() does not dereference arrays

This commit is contained in:
Gavin Howard 2020-05-06 15:28:55 -06:00
parent 25098800a7
commit f3e5367e1f
Signed by: gavin
GPG Key ID: C08038BDF280D33E
1 changed files with 10 additions and 2 deletions

View File

@ -1235,8 +1235,16 @@ static BcStatus bc_program_builtin(BcProgram *p, uchar inst) {
if (len) {
#if BC_ENABLED
if (BC_IS_BC && opd->t == BC_RESULT_ARRAY)
val = (BcBigDig) ((BcVec*) num)->len;
if (BC_IS_BC && opd->t == BC_RESULT_ARRAY) {
BcVec *v = (BcVec*) num;
if (v->size == sizeof(uchar)) v = bc_program_dereference(p, v);
assert(v->size == sizeof(BcNum));
val = (BcBigDig) v->len;
}
else
#endif // BC_ENABLED
{