Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2022-04-11 22:50:52 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2022-04-11 22:59:18 +0300
commit07cacb6d148d7124ba9b6865ca25d585e7d3e4fd (patch)
treef403222a7db564ba6a7caaac918934825d44759b /source/blender/python
parentc4f7f59c659f7d986e4a2602eff4135fc58cf2f1 (diff)
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).
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/gpu/gpu_py_buffer.c11
1 files changed, 9 insertions, 2 deletions
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);