mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Reject NaN and Inf in check_v3d() too
check_v2f() was already doing this
This commit is contained in:
parent
2c260ed206
commit
71d76f6c7b
2 changed files with 16 additions and 0 deletions
|
@ -199,6 +199,9 @@ v3d check_v3d(lua_State *L, int index)
|
|||
double y = lua_tonumber(L, -2);
|
||||
double z = lua_tonumber(L, -1);
|
||||
lua_pop(L, 3);
|
||||
CHECK_FLOAT(x, "x");
|
||||
CHECK_FLOAT(y, "y");
|
||||
CHECK_FLOAT(z, "z");
|
||||
return v3d(x, y, z);
|
||||
}
|
||||
|
||||
|
|
|
@ -180,4 +180,17 @@ void TestScriptApi::testVectorReadMix(MyScriptApi *script)
|
|||
EXCEPTION_CHECK(LuaError, check_v3s16(L, -1));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
// same but even the result is undefined
|
||||
const char *errs2[] = {
|
||||
"return {x=0, y=0, z=0/0}", // nan
|
||||
"return {x=0, y=0, z=math.huge}", // inf
|
||||
};
|
||||
for (auto &it : errs2) {
|
||||
infostream << it << std::endl;
|
||||
run(L, it, 1);
|
||||
(void)read_v3s16(L, -1);
|
||||
EXCEPTION_CHECK(LuaError, check_v3s16(L, -1));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue