From 01ce094adb49ed129305bb3fd72c3d35f5f53fc9 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Thu, 11 Oct 2012 22:34:18 +0100 Subject: [PATCH] Free raw_image if it is unsupported. If the number of colour components is neither 1 nor 3 we should remember to free the buffer holding the raw decoded image before returning the error to Lua. --- pic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pic.c b/pic.c index bad4bfe2d..c0ac8a1fa 100644 --- a/pic.c +++ b/pic.c @@ -142,8 +142,10 @@ static int openDocument(lua_State *L) { return luaL_error(L, "Cannot convert to grayscale"); else doc->image = gray_image; - } else + } else { + free(raw_image); return luaL_error(L, "Unsupported image format"); + } doc->width = width; doc->height = height;