diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp index 70ad3415e..19f11b793 100644 --- a/src/script/common/c_converter.cpp +++ b/src/script/common/c_converter.cpp @@ -28,7 +28,7 @@ extern "C" { #include "common/c_converter.h" #include "common/c_internal.h" #include "constants.h" - +#include #define CHECK_TYPE(index, name, type) { \ int t = lua_type(L, (index)); \ @@ -41,8 +41,8 @@ extern "C" { } #define CHECK_POS_COORD(name) CHECK_TYPE(-1, "position coordinate '" name "'", LUA_TNUMBER) #define CHECK_FLOAT_RANGE(value, name) \ -if (value < F1000_MIN || value > F1000_MAX) { \ - warningstream << "Invalid float vector dimension range '" name "' " << \ +if (value < F1000_MIN || value > F1000_MAX || std::isnan(value) || std::isinf(value) ) { \ + warningstream << "Invalid float vector dimension range or null value given '" name "' " << \ "(expected " << F1000_MIN << " < " name " < " << F1000_MAX << \ " got " << value << "). restarted to max / min" << std::endl; \ if (value < F1000_MIN) \ @@ -166,10 +166,12 @@ v2f check_v2f(lua_State *L, int index) lua_getfield(L, index, "x"); CHECK_POS_COORD("x"); p.X = lua_tonumber(L, -1); + CHECK_FLOAT_RANGE(p.X, "x") lua_pop(L, 1); lua_getfield(L, index, "y"); CHECK_POS_COORD("y"); p.Y = lua_tonumber(L, -1); + CHECK_FLOAT_RANGE(p.Y, "x") lua_pop(L, 1); return p; }