Fix embedded bytecode loader.

This commit is contained in:
Mike Pall
2020-01-13 14:28:43 +01:00
parent 45a7e5073c
commit 8203399601
3 changed files with 8 additions and 1 deletions

View File

@@ -80,6 +80,7 @@ static LJ_NOINLINE void bcread_fill(LexState *ls, MSize len, int need)
ls->current = -1; /* Only bad if we get called again. */
break;
}
if (size >= LJ_MAX_MEM - ls->sb.n) lj_err_mem(ls->L);
if (ls->sb.n) { /* Append to buffer. */
MSize n = ls->sb.n + (MSize)size;
bcread_resize(ls, n < len ? len : n);
@@ -467,7 +468,7 @@ GCproto *lj_bcread(LexState *ls)
setprotoV(L, L->top, pt);
incr_top(L);
}
if ((int32_t)ls->n > 0 || L->top-1 != bcread_oldtop(L, ls))
if ((ls->n && !ls->endmark) || L->top-1 != bcread_oldtop(L, ls))
bcread_error(ls, LJ_ERR_BCBAD);
/* Pop off last prototype. */
L->top--;