mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-11 08:42:35 +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);
|
ImagingSectionLeave(&cookie);
|
||||||
|
|
||||||
WebPPictureFree(&pic);
|
WebPPictureFree(&pic);
|
||||||
|
|
||||||
|
output = writer.mem;
|
||||||
|
ret_size = writer.size;
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
int error_code = (&pic)->error_code;
|
int error_code = (&pic)->error_code;
|
||||||
char message[50] = "";
|
char message[50] = "";
|
||||||
|
@ -652,10 +656,9 @@ WebPEncode_wrapper(PyObject *self, PyObject *args) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
PyErr_Format(PyExc_ValueError, "encoding error %d%s", error_code, message);
|
PyErr_Format(PyExc_ValueError, "encoding error %d%s", error_code, message);
|
||||||
|
free(output);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
output = writer.mem;
|
|
||||||
ret_size = writer.size;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
/* I want to truncate the *_size items that get passed into WebP
|
/* I want to truncate the *_size items that get passed into WebP
|
||||||
|
|
Loading…
Reference in New Issue
Block a user