From 9a0ded7d6d9159549625bbe6ee56ffb1cc901ad7 Mon Sep 17 00:00:00 2001
From: Dmitry Simonenko <pmwkaa@gmail.com>
Date: Wed, 14 Mar 2012 19:40:28 +0400
Subject: [PATCH] core-lua-i64: fixed lua_pushcdata for proper box.unpack
 multiret, test case

---
 core/tarantool_lua.m    |  7 ++++---
 test/box_big/lua.result | 15 +++++++++++++++
 test/box_big/lua.test   |  4 ++++
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/core/tarantool_lua.m b/core/tarantool_lua.m
index 32790e1001..951baf5d8b 100644
--- a/core/tarantool_lua.m
+++ b/core/tarantool_lua.m
@@ -38,6 +38,7 @@
 #include "lj_ctype.h"
 #include "lj_cdata.h"
 #include "lj_cconv.h"
+#include "lj_state.h"
 
 #include "pickle.h"
 #include "fiber.h"
@@ -252,10 +253,10 @@ luaL_pushcdata(struct lua_State *L, CTypeID id, int bits)
 	CTSize sz;
 	lj_ctype_info(cts, id, &sz);
 	GCcdata *cd = lj_cdata_new(cts, id, bits);
-	TValue *o = L->base + 1;
-	setcdataV(L, o - 1, cd);
+	TValue *o = L->top;
+	setcdataV(L, o, cd);
 	lj_cconv_ct_init(cts, ct, sz, cdataptr(cd), o, 0);
-	L->top = o;
+	incr_top(L);
 	return cd;
 }
 
diff --git a/test/box_big/lua.result b/test/box_big/lua.result
index 9b60d8228a..7824c223fa 100644
--- a/test/box_big/lua.result
+++ b/test/box_big/lua.result
@@ -95,3 +95,18 @@ lua num == tonumber64('18446744073709551615')
 ---
  - true
 ...
+lua num,num1,num2 = box.unpack('lll', tu[0], tu[0], tu[0])
+---
+...
+lua num == tonumber64('18446744073709551615')
+---
+ - true
+...
+lua num1 == tonumber64('18446744073709551615')
+---
+ - true
+...
+lua num2 == tonumber64('18446744073709551615')
+---
+ - true
+...
diff --git a/test/box_big/lua.test b/test/box_big/lua.test
index 0c43ab7c6b..557f85498b 100644
--- a/test/box_big/lua.test
+++ b/test/box_big/lua.test
@@ -47,3 +47,7 @@ exec admin "lua num = box.unpack('l', tu[0])"
 exec admin "lua print(num)"
 exec admin "lua type(num) == 'cdata'"
 exec admin "lua num == tonumber64('18446744073709551615')"
+exec admin "lua num,num1,num2 = box.unpack('lll', tu[0], tu[0], tu[0])"
+exec admin "lua num == tonumber64('18446744073709551615')"
+exec admin "lua num1 == tonumber64('18446744073709551615')"
+exec admin "lua num2 == tonumber64('18446744073709551615')"
-- 
GitLab