Lua: fix crash with unary not (~) on boolean constant/nil and let it work on boolean/nil values in general

This commit is contained in:
James R 2020-11-20 19:17:32 -08:00
parent 85c5fa9527
commit 42c72b7b0d

View file

@ -541,11 +541,14 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue;
}
case OP_BNOT: {
TValue *rb = RB(i);
TValue *rb = RKB(i);
if (ttisnumber(rb)) {
lua_Number nb = nvalue(rb);
setnvalue(ra, luai_numnot(nb));
}
else if (ttisboolean(rb) || ttisnil(rb)) {
setbvalue(ra, l_isfalse(rb));
}
else {
Protect(Arith(L, ra, rb, rb, TM_NOT));
}