summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-11-16 14:35:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-11-16 14:35:06 -0300
commit6b3e116d44eed387aa93126c48eae8a64b38bfc2 (patch)
tree04175aafa7c2ca0d24c41eb3e5115859705bd06f
parente8deac5a41ffd644aaa78fda6d4bd5caa72cb077 (diff)
downloadlua-github-6b3e116d44eed387aa93126c48eae8a64b38bfc2.tar.gz
Corrected bug in 'luaD_tryfuncTM'
The pointer to the metamethod can be invalidated by a finalizer that can run during a GC in 'checkstackGCp'. (This commit also fixes a detail in the manual.) Bug introduced in commit 91673a8ec.
-rw-r--r--ldo.c3
-rw-r--r--manual/manual.of2
2 files changed, 3 insertions, 2 deletions
diff --git a/ldo.c b/ldo.c
index 66f89036..f282a773 100644
--- a/ldo.c
+++ b/ldo.c
@@ -388,9 +388,10 @@ static void rethook (lua_State *L, CallInfo *ci, int nres) {
** an error if there is no '__call' metafield.
*/
StkId luaD_tryfuncTM (lua_State *L, StkId func) {
- const TValue *tm = luaT_gettmbyobj(L, s2v(func), TM_CALL);
+ const TValue *tm;
StkId p;
checkstackGCp(L, 1, func); /* space for metamethod */
+ tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); /* (after previous GC) */
if (l_unlikely(ttisnil(tm)))
luaG_callerror(L, s2v(func)); /* nothing to call */
for (p = L->top; p > func; p--) /* open space for metamethod */
diff --git a/manual/manual.of b/manual/manual.of
index 9e0b8835..c9e62b49 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -6247,7 +6247,7 @@ to its caller.
}
@LibEntry{error (message [, level])|
-Raises an error @see{error} with @{message} as the error object.
+Raises an error @see{error} with @id{message} as the error object.
This function never returns.
Usually, @id{error} adds some information about the error position