Commit baeb5be4 authored by Stefan Behnel's avatar Stefan Behnel

Release buffer on validation errors. My guess is that we previously just...

Release buffer on validation errors. My guess is that we previously just leaked the buffer owner in that case.
parent c6d0a5c8
......@@ -742,7 +742,11 @@ static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
return 0;
}
buf->buf = NULL;
if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
if (__Pyx_GetBuffer(obj, buf, flags) == -1) {
__Pyx_ZeroBuffer(buf);
return -1;
}
// From this point on, we have acquired the buffer and must release it on errors.
if (buf->ndim != nd) {
PyErr_Format(PyExc_ValueError,
"Buffer has wrong number of dimensions (expected %d, got %d)",
......@@ -764,7 +768,7 @@ static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
return 0;
fail:;
__Pyx_ZeroBuffer(buf);
__Pyx_SafeReleaseBuffer(buf);
return -1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment