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.
This commit is contained in:
Roberto Ierusalimschy
2024-07-16 11:33:30 -03:00
parent 6b45ccf4ed
commit cd4de92762
5 changed files with 46 additions and 28 deletions

View File

@@ -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}