Fix T94202: GPUFrameBuffer: wrong refcount in the buffer passed for read_color and read_depth
The buffer passed as an argument to `GPUFrameBuffer.read_color` is used in the return of the function and therefore, if not used, its refcount is decremented. So be sure to increment the refcount of the already existing objects that will be used in the return of a function.
This commit is contained in:
parent
822501d86d
commit
63b9e5378b
Notes:
blender-bot
2023-02-14 02:58:19 +01:00
Referenced by issue #94202, crash or error when using GPUFrameBuffer.read_color(... data=data) Referenced by issue #93479, 3.0 Potential candidates for corrective releases
|
@ -530,6 +530,7 @@ static PyObject *pygpu_framebuffer_read_color(BPyGPUFrameBuffer *self,
|
|||
PyErr_SetString(PyExc_BufferError, "the buffer size is smaller than expected");
|
||||
return NULL;
|
||||
}
|
||||
Py_INCREF(py_buffer);
|
||||
}
|
||||
else {
|
||||
py_buffer = BPyGPU_Buffer_CreatePyObject(
|
||||
|
@ -590,6 +591,7 @@ static PyObject *pygpu_framebuffer_read_depth(BPyGPUFrameBuffer *self,
|
|||
PyErr_SetString(PyExc_BufferError, "the buffer size is smaller than expected");
|
||||
return NULL;
|
||||
}
|
||||
Py_INCREF(py_buffer);
|
||||
}
|
||||
else {
|
||||
py_buffer = BPyGPU_Buffer_CreatePyObject(GPU_DATA_FLOAT, (Py_ssize_t[]){h, w}, 2, NULL);
|
||||
|
|
Loading…
Reference in New Issue