mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-10 16:22:22 +03:00
Fix leak in webp_encode
* Free the output buffer on webp encode error
This commit is contained in:
parent
84b88a9fbc
commit
eaab435403
|
@ -641,6 +641,10 @@ WebPEncode_wrapper(PyObject *self, PyObject *args) {
|
|||
ImagingSectionLeave(&cookie);
|
||||
|
||||
WebPPictureFree(&pic);
|
||||
|
||||
output = writer.mem;
|
||||
ret_size = writer.size;
|
||||
|
||||
if (!ok) {
|
||||
int error_code = (&pic)->error_code;
|
||||
char message[50] = "";
|
||||
|
@ -652,10 +656,9 @@ WebPEncode_wrapper(PyObject *self, PyObject *args) {
|
|||
);
|
||||
}
|
||||
PyErr_Format(PyExc_ValueError, "encoding error %d%s", error_code, message);
|
||||
free(output);
|
||||
return NULL;
|
||||
}
|
||||
output = writer.mem;
|
||||
ret_size = writer.size;
|
||||
|
||||
{
|
||||
/* I want to truncate the *_size items that get passed into WebP
|
||||
|
|
Loading…
Reference in New Issue
Block a user