mirror of
https://github.com/love2d/love.git
synced 2026-08-18 11:44:15 +02:00
Fixed undefined behaviour when love exceptions are converted into Lua errors (resolves issue #729)
This commit is contained in:
@@ -36,14 +36,9 @@ int w_CompressedData_getWidth(lua_State *L)
|
||||
CompressedData *t = luax_checkcompresseddata(L, 1);
|
||||
int miplevel = luaL_optinteger(L, 2, 1);
|
||||
int width = 0;
|
||||
try
|
||||
{
|
||||
width = t->getWidth(miplevel >= 1 ? miplevel - 1 : 0);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
|
||||
EXCEPT_GUARD(width = t->getWidth(miplevel >= 1 ? miplevel - 1 : 0);)
|
||||
|
||||
lua_pushinteger(L, width);
|
||||
return 1;
|
||||
}
|
||||
@@ -53,14 +48,9 @@ int w_CompressedData_getHeight(lua_State *L)
|
||||
CompressedData *t = luax_checkcompresseddata(L, 1);
|
||||
int miplevel = luaL_optinteger(L, 2, 1);
|
||||
int height = 0;
|
||||
try
|
||||
{
|
||||
height = t->getHeight(miplevel >= 1 ? miplevel - 1 : 0);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
|
||||
EXCEPT_GUARD(height = t->getHeight(miplevel >= 1 ? miplevel - 1 : 0);)
|
||||
|
||||
lua_pushinteger(L, height);
|
||||
return 1;
|
||||
}
|
||||
@@ -70,15 +60,12 @@ int w_CompressedData_getDimensions(lua_State *L)
|
||||
CompressedData *t = luax_checkcompresseddata(L, 1);
|
||||
int miplevel = luaL_optinteger(L, 2, 1);
|
||||
int width = 0, height = 0;
|
||||
try
|
||||
{
|
||||
|
||||
EXCEPT_GUARD(
|
||||
width = t->getWidth(miplevel >= 1 ? miplevel - 1 : 0);
|
||||
height = t->getHeight(miplevel >= 1 ? miplevel - 1 : 0);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
)
|
||||
|
||||
lua_pushinteger(L, width);
|
||||
lua_pushinteger(L, height);
|
||||
return 2;
|
||||
|
||||
Reference in New Issue
Block a user