Skip to content

Commit 96b6ad6

Browse files
committed
Bug in __lanesclone with 3 parameters mechanism fixed (index was wrong in inter_copy_function); Some comments improved
1 parent 61f1b4a commit 96b6ad6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/tools.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,10 +1674,10 @@ static bool_t inter_copy_function( Universe* U, lua_State* L2, uint_t L2_cache_i
16741674

16751675
// this function has 2 upvalues: the fqn of its metatable, and the userdata itself
16761676
lookup_table( L2, L, source_i_, mode_, upName_); // ... mt
1677-
// originally 'i' slot was the proxy closure, but from now on it indexes the actual userdata we extracted from it
1677+
// originally 'source_i_' slot was the proxy closure, but from now on it indexes the actual userdata we extracted from it
16781678
source_i_ = lua_gettop( L);
16791679
source = lua_touserdata( L, -1);
1680-
// call the cloning function with 1 argument, should return the number of bytes to allocate for the clone
1680+
// get the number of bytes to allocate for the clone
16811681
userdata_size = (size_t) lua_rawlen( L, -1);
16821682
{
16831683
// extract uservalues (don't transfer them yet)
@@ -1713,12 +1713,12 @@ static bool_t inter_copy_function( Universe* U, lua_State* L2, uint_t L2_cache_i
17131713
// perform the custom cloning part
17141714
lua_insert( L2, -2); // ... u mt
17151715
// __lanesclone should always exist because we wouldn't be restoring data from a userdata_clone_sentinel closure to begin with
1716-
lua_getfield(L2, -2, "__lanesclone"); // ... u mt __lanesclone
1716+
lua_getfield(L2, -1, "__lanesclone"); // ... u mt __lanesclone
17171717
lua_remove( L2, -2); // ... u __lanesclone
17181718
lua_pushlightuserdata( L2, clone); // ... u __lanesclone clone
17191719
lua_pushlightuserdata( L2, source); // ... u __lanesclone clone source
17201720
lua_pushinteger( L2, userdata_size); // ... u __lanesclone clone source size
1721-
// clone:__lanesclone(source, size)
1721+
// clone:__lanesclone(dest, source, size)
17221722
lua_call( L2, 3, 0); // ... u
17231723
}
17241724
else // regular function

0 commit comments

Comments
 (0)