Thanks for the patch! See 4 comments below.
On 13/07/2018 14:21, Kirill Shcherbatov wrote:
Function tonumber64 has worked incorrectly with values less
than LLONG_MIN.
Now it works in the interval [LLONG_MIN, ULLONG_MAX] returning
nil otherwise.
Closes #3466.
---
Branch:
https://github.com/tarantool/tarantool/compare/kshch/gh-3466-tonumber64-strange-behaviour
Issue: https://github.com/tarantool/tarantool/issues/3466
src/lua/init.c | 6 +++++-
test/box/misc.result | 19 +++++++++++++++++++
test/box/misc.test.lua | 8 ++++++++
3 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/src/lua/init.c b/src/lua/init.c
index 9a96030..4b5285d 100644
--- a/src/lua/init.c
+++ b/src/lua/init.c
@@ -222,7 +222,11 @@ lbox_tonumber64(struct lua_State *L)
if (argl == 0) {
lua_pushnil(L);
} else if (negative) {
- luaL_pushint64(L, -1 * (long long )result);
+ if (result > -((unsigned long long )LLONG_MIN))
{
+ lua_pushnil(L);
+ } else {
+ luaL_pushint64(L, -result);
+ }
} else {
luaL_pushuint64(L, result);
}