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.
This commit is contained in:
Tigran Aivazian
2012-10-11 22:34:18 +01:00
committed by Qingping Hou
parent 74a60eeea2
commit 01ce094adb

4
pic.c
View File

@@ -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;