mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Merge pull request #4381 from radarhere/memory
Release buffer if function returns prematurely
This commit is contained in:
commit
5e4b6e9378
|
@ -354,17 +354,21 @@ PyImaging_MapBuffer(PyObject* self, PyObject* args)
|
|||
|
||||
if (view.len < 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "buffer has negative size");
|
||||
PyBuffer_Release(&view);
|
||||
return NULL;
|
||||
}
|
||||
if (offset + size > view.len) {
|
||||
PyErr_SetString(PyExc_ValueError, "buffer is not large enough");
|
||||
PyBuffer_Release(&view);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
im = ImagingNewPrologueSubtype(
|
||||
mode, xsize, ysize, sizeof(ImagingBufferInstance));
|
||||
if (!im)
|
||||
if (!im) {
|
||||
PyBuffer_Release(&view);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* setup file pointers */
|
||||
if (ystep > 0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user