From cd4de92762434e6ed0e6c207d56d365300396dd8 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 16 Jul 2024 11:33:30 -0300 Subject: Maximum stack size may not fit in unsigned short Therefore, fields ftransfer/ntransfer in lua_Debug must have type 'int'. (Maximum stack size must fit in an 'int'.) Also, this commit adds check that maximum stack size respects size_t for size in bytes. --- manual/manual.of | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'manual') diff --git a/manual/manual.of b/manual/manual.of index 56619afe..1069f644 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -4262,8 +4262,9 @@ you push the main function plus any arguments onto the empty stack of the thread. then you call @Lid{lua_resume}, with @id{nargs} being the number of arguments. -This call returns when the coroutine suspends or finishes its execution. -When it returns, +The function returns when the coroutine suspends, +finishes its execution, or raises an unprotected error. +When it returns without errors, @id{*nresults} is updated and the top of the stack contains the @id{*nresults} values passed to @Lid{lua_yield} @@ -4274,9 +4275,11 @@ or returned by the body function. without errors, or an error code in case of errors @see{statuscodes}. In case of errors, -the error object is on the top of the stack. +the error object is pushed on the top of the stack. +(In that case, @id{nresults} is not updated, +as its value would have to be 1 for the sole error object.) -To resume a coroutine, +To resume a suspended coroutine, you remove the @id{*nresults} yielded values from its stack, push the values to be passed as results from @id{yield}, and then call @Lid{lua_resume}. @@ -4822,8 +4825,8 @@ typedef struct lua_Debug { unsigned char nparams; /* (u) number of parameters */ char isvararg; /* (u) */ char istailcall; /* (t) */ - unsigned short ftransfer; /* (r) index of first value transferred */ - unsigned short ntransfer; /* (r) number of transferred values */ + int ftransfer; /* (r) index of first value transferred */ + int ntransfer; /* (r) number of transferred values */ char short_src[LUA_IDSIZE]; /* (S) */ /* private part */ @rep{other fields} -- cgit v1.2.3-55-g6feb