mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
Got_Luacmd: ensure lua stack is large enough for command arguments
This commit is contained in:
parent
da84a94362
commit
42bca87c9a
1 changed files with 14 additions and 2 deletions
|
|
@ -30,6 +30,12 @@ return luaL_error(L, "HUD rendering code should not call this function!");
|
||||||
|
|
||||||
static consvar_t *this_cvar;
|
static consvar_t *this_cvar;
|
||||||
|
|
||||||
|
static void clear_lua_stack(void)
|
||||||
|
{
|
||||||
|
if (gL) // check if Lua is actually turned on first, you dummmy -- Monster Iestyn 04/07/18
|
||||||
|
lua_settop(gL, 0); // clear stack
|
||||||
|
}
|
||||||
|
|
||||||
void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
||||||
{
|
{
|
||||||
UINT8 i, argc, flags;
|
UINT8 i, argc, flags;
|
||||||
|
|
@ -74,6 +80,13 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
||||||
|
|
||||||
lua_remove(gL, -2); // pop command info table
|
lua_remove(gL, -2); // pop command info table
|
||||||
|
|
||||||
|
if (!lua_checkstack(gL, argc)) // player + command arguments
|
||||||
|
{
|
||||||
|
clear_lua_stack();
|
||||||
|
CONS_Alert(CONS_WARNING, "lua command stack overflow from %s (%d, need %d more)\n", player_names[playernum], lua_gettop(gL), argc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LUA_PushUserdata(gL, &players[playernum], META_PLAYER);
|
LUA_PushUserdata(gL, &players[playernum], META_PLAYER);
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -85,8 +98,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
||||||
|
|
||||||
deny:
|
deny:
|
||||||
//must be hacked/buggy client
|
//must be hacked/buggy client
|
||||||
if (gL) // check if Lua is actually turned on first, you dummmy -- Monster Iestyn 04/07/18
|
clear_lua_stack();
|
||||||
lua_settop(gL, 0); // clear stack
|
|
||||||
|
|
||||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal lua command received from %s\n"), player_names[playernum]);
|
CONS_Alert(CONS_WARNING, M_GetText("Illegal lua command received from %s\n"), player_names[playernum]);
|
||||||
if (server)
|
if (server)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue