From c0661abc61a6f7d5dacd1d62477a6e6c44fbd217 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 26 Aug 2009 21:17:10 +0200 Subject: [PATCH] image.argb32(): Check for zero height or width This makes image.argb32() fail in a better way if it is called with a zero size. Bug found by anrxc and reported a FS#597 and FS#599. Signed-off-by: Uli Schlachter Signed-off-by: Julien Danjou --- image.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/image.c b/image.c index a31709ca4..a472133d5 100644 --- a/image.c +++ b/image.c @@ -303,6 +303,11 @@ luaA_image_argb32_new(lua_State *L) unsigned int width = luaL_checknumber(L, 1); unsigned int height = luaL_checknumber(L, 2); + if (width == 0) + luaL_error(L, "image.argb32() called with zero width"); + if (height == 0) + luaL_error(L, "image.argb32() called with zero height"); + if(lua_isnil(L, 3)) { uint32_t *data = p_new(uint32_t, width * height);