[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46904] trunk/blender/source/blender/gpu/ intern/gpu_buffers.c: Fix memory leak when deleting all vertices from mesh with certain modifiers (bevel and array among them) and VBO are enabled.

Antony Riakiotakis kalast at gmail.com
Tue May 22 19:33:58 CEST 2012


Revision: 46904
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46904
Author:   psy-fi
Date:     2012-05-22 17:33:58 +0000 (Tue, 22 May 2012)
Log Message:
-----------
Fix memory leak when deleting all vertices from mesh with certain modifiers (bevel and array among them) and VBO are enabled.

Modified Paths:
--------------
    trunk/blender/source/blender/gpu/intern/gpu_buffers.c

Modified: trunk/blender/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_buffers.c	2012-05-22 16:24:09 UTC (rev 46903)
+++ trunk/blender/source/blender/gpu/intern/gpu_buffers.c	2012-05-22 17:33:58 UTC (rev 46904)
@@ -102,7 +102,7 @@
 	if (useVBOs == -1)
 		useVBOs = (GLEW_ARB_vertex_buffer_object ? 1 : 0);
 
-	pool = MEM_callocN(sizeof(GPUBufferPool), "GPUBuffer");
+	pool = MEM_callocN(sizeof(GPUBufferPool), "GPUBuffer_Pool");
 
 	pool->maxsize = MAX_FREE_GPU_BUFFERS;
 	pool->buffers = MEM_callocN(sizeof(GPUBuffer *) * pool->maxsize,
@@ -192,6 +192,12 @@
 	GPUBuffer *buf;
 	int i, bufsize, bestfit = -1;
 
+	/* bad case, leads to leak of buf since buf->pointer will allocate
+	 * NULL, leading to return without cleanup. In any case better detect early
+	 * psy-fi */
+	if(size == 0)
+		return NULL;
+
 	pool = gpu_get_global_buffer_pool();
 
 	/* not sure if this buffer pool code has been profiled much,




More information about the Bf-blender-cvs mailing list