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 <psychon@znc.in>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Uli Schlachter 2009-08-26 21:17:10 +02:00 committed by Julien Danjou
parent 1c57970dd9
commit c0661abc61
1 changed files with 5 additions and 0 deletions

View File

@ -303,6 +303,11 @@ luaA_image_argb32_new(lua_State *L)
unsigned int width = luaL_checknumber(L, 1); unsigned int width = luaL_checknumber(L, 1);
unsigned int height = luaL_checknumber(L, 2); 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)) if(lua_isnil(L, 3))
{ {
uint32_t *data = p_new(uint32_t, width * height); uint32_t *data = p_new(uint32_t, width * height);