Fixed undefined behaviour when love exceptions are converted into Lua errors (resolves issue #729)

This commit is contained in:
Alex Szpakowski
2013-09-05 23:17:29 -03:00
parent 389e99bf2c
commit 06f80d5c08
45 changed files with 349 additions and 873 deletions
+10 -23
View File
@@ -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;