[Bf-blender-cvs] [07cacb6d148] master: Fix crash when creating a 'gpu.types.Buffer'
Germano Cavalcante
noreply at git.blender.org
Mon Apr 11 21:59:43 CEST 2022
Commit: 07cacb6d148d7124ba9b6865ca25d585e7d3e4fd
Author: Germano Cavalcante
Date: Mon Apr 11 16:50:52 2022 -0300
Branches: master
https://developer.blender.org/rB07cacb6d148d7124ba9b6865ca25d585e7d3e4fd
Fix crash when creating a 'gpu.types.Buffer'
Buffer creation may crash when passed a PyBuffer with no `shape` defined.
(Which is common for strucs).
===================================================================
M source/blender/python/gpu/gpu_py_buffer.c
===================================================================
diff --git a/source/blender/python/gpu/gpu_py_buffer.c b/source/blender/python/gpu/gpu_py_buffer.c
index e0c20b64c63..82c9f8f1f04 100644
--- a/source/blender/python/gpu/gpu_py_buffer.c
+++ b/source/blender/python/gpu/gpu_py_buffer.c
@@ -394,9 +394,16 @@ static PyObject *pygpu_buffer__tp_new(PyTypeObject *UNUSED(type), PyObject *args
return NULL;
}
- if (pygpu_buffer_dimensions_tot_len_compare(shape, shape_len, pybuffer.shape, pybuffer.ndim)) {
+ Py_ssize_t *pybuffer_shape = pybuffer.shape;
+ Py_ssize_t pybuffer_ndim = pybuffer.ndim;
+ if (!pybuffer_shape) {
+ pybuffer_shape = &pybuffer.len;
+ pybuffer_ndim = 1;
+ }
+
+ if (pygpu_buffer_dimensions_tot_len_compare(shape, shape_len, pybuffer_shape, pybuffer_ndim)) {
buffer = pygpu_buffer_make_from_data(
- init, pygpu_dataformat.value_found, pybuffer.ndim, shape, pybuffer.buf);
+ init, pygpu_dataformat.value_found, shape_len, shape, pybuffer.buf);
}
PyBuffer_Release(&pybuffer);
More information about the Bf-blender-cvs
mailing list