Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release buffer if function returns prematurely #4381

Merged
merged 1 commit into from Mar 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/map.c
Expand Up @@ -355,17 +355,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)
Expand Down