Fix Py_buffer leak on GetBuffer failure

Fixes #852.
This commit is contained in:
Jason Rhinelander 2017-05-16 09:38:58 -04:00
parent 4567f1f82a
commit 731a9f6cea

View File

@ -1155,8 +1155,10 @@ public:
int flags = PyBUF_STRIDES | PyBUF_FORMAT; int flags = PyBUF_STRIDES | PyBUF_FORMAT;
if (writable) flags |= PyBUF_WRITABLE; if (writable) flags |= PyBUF_WRITABLE;
Py_buffer *view = new Py_buffer(); Py_buffer *view = new Py_buffer();
if (PyObject_GetBuffer(m_ptr, view, flags) != 0) if (PyObject_GetBuffer(m_ptr, view, flags) != 0) {
delete view;
throw error_already_set(); throw error_already_set();
}
return buffer_info(view); return buffer_info(view);
} }
}; };