[Bf-blender-cvs] [63b9e5378b8] blender-v3.0-release: Fix T94202: GPUFrameBuffer: wrong refcount in the buffer passed for read_color and read_depth

Germano Cavalcante noreply at git.blender.org
Thu Jan 20 21:25:30 CET 2022


Commit: 63b9e5378b81fc1a184210c7f3ccf3e452ffbbe4
Author: Germano Cavalcante
Date:   Tue Jan 18 19:23:08 2022 -0300
Branches: blender-v3.0-release
https://developer.blender.org/rB63b9e5378b81fc1a184210c7f3ccf3e452ffbbe4

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.

===================================================================

M	source/blender/python/gpu/gpu_py_framebuffer.c

===================================================================

diff --git a/source/blender/python/gpu/gpu_py_framebuffer.c b/source/blender/python/gpu/gpu_py_framebuffer.c
index a9347b71723..412fcac02ca 100644
--- a/source/blender/python/gpu/gpu_py_framebuffer.c
+++ b/source/blender/python/gpu/gpu_py_framebuffer.c
@@ -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);



More information about the Bf-blender-cvs mailing list