From 0e0a7d21555f3118676f8baf1e46158f5ae452d0 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Tue, 31 Mar 2026 20:38:52 -0300 Subject: [PATCH] don't allow invalid types for the second param of readbackTexture. --- src/modules/graphics/wrap_Graphics.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/graphics/wrap_Graphics.cpp b/src/modules/graphics/wrap_Graphics.cpp index a423453a4..beab3df90 100644 --- a/src/modules/graphics/wrap_Graphics.cpp +++ b/src/modules/graphics/wrap_Graphics.cpp @@ -2395,6 +2395,8 @@ int w_readbackTexture(lua_State *L) int slice = 0; if (t->getTextureType() != TEXTURE_2D) slice = (int) luaL_checkinteger(L, 2) - 1; + else if (!lua_isnoneornil(L, 2) && lua_type(L, 2) != LUA_TNUMBER) + luaL_argerror(L, 2, "number or nil expected"); int mipmap = (int) luaL_optinteger(L, 3, 1) - 1; @@ -2433,6 +2435,8 @@ int w_readbackTextureAsync(lua_State *L) int slice = 0; if (t->getTextureType() != TEXTURE_2D) slice = (int) luaL_checkinteger(L, 2) - 1; + else if (!lua_isnoneornil(L, 2) && lua_type(L, 2) != LUA_TNUMBER) + luaL_argerror(L, 2, "number or nil expected"); int mipmap = (int) luaL_optinteger(L, 3, 1) - 1;