Fix cases where 'Py_buffer' might not be released
This commit is contained in:
@@ -70,12 +70,14 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar
|
|||||||
|
|
||||||
if (pybuffer.ndim != 1 && pybuffer.shape[1] != verts_per_prim) {
|
if (pybuffer.ndim != 1 && pybuffer.shape[1] != verts_per_prim) {
|
||||||
PyErr_Format(PyExc_ValueError, "Each primitive must exactly %d indices", verts_per_prim);
|
PyErr_Format(PyExc_ValueError, "Each primitive must exactly %d indices", verts_per_prim);
|
||||||
|
PyBuffer_Release(&pybuffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pybuffer.itemsize != 4 ||
|
if (pybuffer.itemsize != 4 ||
|
||||||
PyC_StructFmt_type_is_float_any(PyC_StructFmt_type_from_str(pybuffer.format))) {
|
PyC_StructFmt_type_is_float_any(PyC_StructFmt_type_from_str(pybuffer.format))) {
|
||||||
PyErr_Format(PyExc_ValueError, "Each index must be an 4-bytes integer value");
|
PyErr_Format(PyExc_ValueError, "Each index must be an 4-bytes integer value");
|
||||||
|
PyBuffer_Release(&pybuffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user