diff options
author | Benoit Germain <bnt period germain arrobase gmail period com> | 2014-01-22 16:16:46 +0100 |
---|---|---|
committer | Benoit Germain <bnt period germain arrobase gmail period com> | 2014-01-22 16:16:46 +0100 |
commit | ae19ebab381e6902cce2c7a3efd4a0949357c866 (patch) | |
tree | 466558c1533fd8945cc6cfd08535f74dc5f38a10 /src | |
parent | 9808ae3e21ac812ef705a7c1a0b10f49825023c5 (diff) | |
download | lanes-ae19ebab381e6902cce2c7a3efd4a0949357c866.tar.gz lanes-ae19ebab381e6902cce2c7a3efd4a0949357c866.tar.bz2 lanes-ae19ebab381e6902cce2c7a3efd4a0949357c866.zip |
2 crash fixes and 1 experiment
* bumped version to 3.8.3
* fixed a possible Lua stack overflow when sending complex function
through lindas or as lane body
* experimental: lanes.nameof() scans the registry if a regular search
didn't yield anything interesting
* fixed lanes.nameof() misbehaving when encountering a LUA_TTHREAD
object
Diffstat (limited to 'src')
-rw-r--r-- | src/lanes.c | 2 | ||||
-rw-r--r-- | src/tools.c | 22 |
2 files changed, 14 insertions, 10 deletions
diff --git a/src/lanes.c b/src/lanes.c index a806c16..270c01d 100644 --- a/src/lanes.c +++ b/src/lanes.c | |||
@@ -52,7 +52,7 @@ | |||
52 | * ... | 52 | * ... |
53 | */ | 53 | */ |
54 | 54 | ||
55 | char const* VERSION = "3.8.2"; | 55 | char const* VERSION = "3.8.3"; |
56 | 56 | ||
57 | /* | 57 | /* |
58 | =============================================================================== | 58 | =============================================================================== |
diff --git a/src/tools.c b/src/tools.c index 9f36858..e456db7 100644 --- a/src/tools.c +++ b/src/tools.c | |||
@@ -1443,14 +1443,7 @@ static int discover_object_name_recur( lua_State* L, int shortest_, int depth_) | |||
1443 | break; | 1443 | break; |
1444 | 1444 | ||
1445 | case LUA_TTHREAD: // o "r" {c} {fqn} ... {?} k T | 1445 | case LUA_TTHREAD: // o "r" {c} {fqn} ... {?} k T |
1446 | // search in the object's uservalue if it is a table | 1446 | // TODO: explore the thread's stack frame looking for our culprit? |
1447 | lua_getuservalue( L, -1); // o "r" {c} {fqn} ... {?} k T {u} | ||
1448 | if( lua_istable( L, -1)) | ||
1449 | { | ||
1450 | shortest_ = discover_object_name_recur( L, shortest_, depth_); | ||
1451 | } | ||
1452 | lua_pop( L, 1); // o "r" {c} {fqn} ... {?} k T | ||
1453 | STACK_MID( L, 2); | ||
1454 | break; | 1447 | break; |
1455 | 1448 | ||
1456 | case LUA_TUSERDATA: // o "r" {c} {fqn} ... {?} k U | 1449 | case LUA_TUSERDATA: // o "r" {c} {fqn} ... {?} k U |
@@ -1531,9 +1524,19 @@ int luaG_nameof( lua_State* L) | |||
1531 | lua_newtable( L); // o nil {c} | 1524 | lua_newtable( L); // o nil {c} |
1532 | // push a table whose contents are strings that, when concatenated, produce unique name | 1525 | // push a table whose contents are strings that, when concatenated, produce unique name |
1533 | lua_newtable( L); // o nil {c} {fqn} | 1526 | lua_newtable( L); // o nil {c} {fqn} |
1527 | lua_pushliteral( L, "_G"); // o nil {c} {fqn} "_G" | ||
1528 | lua_rawseti( L, -2, 1); // o nil {c} {fqn} | ||
1534 | // this is where we start the search | 1529 | // this is where we start the search |
1535 | lua_pushglobaltable( L); // o nil {c} {fqn} _G | 1530 | lua_pushglobaltable( L); // o nil {c} {fqn} _G |
1536 | (void) discover_object_name_recur( L, 6666, 0); | 1531 | (void) discover_object_name_recur( L, 6666, 1); |
1532 | if( lua_isnil( L, 2)) // try again with registry, just in case... | ||
1533 | { | ||
1534 | lua_pop( L, 1); // o nil {c} {fqn} | ||
1535 | lua_pushliteral( L, "_R"); // o nil {c} {fqn} "_R" | ||
1536 | lua_rawseti( L, -2, 1); // o nil {c} {fqn} | ||
1537 | lua_pushvalue( L, LUA_REGISTRYINDEX); // o nil {c} {fqn} _R | ||
1538 | (void) discover_object_name_recur( L, 6666, 1); | ||
1539 | } | ||
1537 | lua_pop( L, 3); // o "result" | 1540 | lua_pop( L, 3); // o "result" |
1538 | STACK_END( L, 1); | 1541 | STACK_END( L, 1); |
1539 | lua_pushstring( L, luaL_typename( L, 1)); // o "result" "type" | 1542 | lua_pushstring( L, luaL_typename( L, 1)); // o "result" "type" |
@@ -1606,6 +1609,7 @@ static void lookup_native_func( lua_State* L2, lua_State* L, uint_t i, enum eLoo | |||
1606 | STACK_END( L, 0); | 1609 | STACK_END( L, 0); |
1607 | // push the equivalent function in the destination's stack, retrieved from the lookup table | 1610 | // push the equivalent function in the destination's stack, retrieved from the lookup table |
1608 | STACK_CHECK( L2); | 1611 | STACK_CHECK( L2); |
1612 | STACK_GROW( L2, 2); | ||
1609 | if( mode_ == eLM_ToKeeper) | 1613 | if( mode_ == eLM_ToKeeper) |
1610 | { | 1614 | { |
1611 | // push a sentinel closure that holds the lookup name as upvalue | 1615 | // push a sentinel closure that holds the lookup name as upvalue |