From f993fe99d39742c608dd11c1fb2bbf46844ed234 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sat, 2 Jul 2011 16:24:58 +0200 Subject: [PATCH] Catch errors in getPixel and setPixel (bug #93) --- src/modules/image/wrap_ImageData.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/modules/image/wrap_ImageData.cpp b/src/modules/image/wrap_ImageData.cpp index a6f61c44e..5541f5217 100644 --- a/src/modules/image/wrap_ImageData.cpp +++ b/src/modules/image/wrap_ImageData.cpp @@ -51,7 +51,15 @@ namespace image ImageData * t = luax_checkimagedata(L, 1); int x = luaL_checkint(L, 2); int y = luaL_checkint(L, 3); - pixel c = t->getPixel(x, y); + pixel c; + try + { + pixel c = t->getPixel(x, y); + } + catch (love::Exception *e) + { + return luaL_error(L, "%s", e->what()); + } lua_pushnumber(L, c.r); lua_pushnumber(L, c.g); lua_pushnumber(L, c.b); @@ -69,7 +77,14 @@ namespace image c.g = luaL_checkint(L, 5); c.b = luaL_checkint(L, 6); c.a = luaL_checkint(L, 7); - t->setPixel(x, y, c); + try + { + t->setPixel(x, y, c); + } + catch (love::Exception *e) + { + return luaL_error(L, "%s", e->what()); + } return 0; }