Fix memory leak when deleting all vertices from mesh with certain modifiers (bevel and array among them) and VBO are enabled.

This commit is contained in:
Antony Riakiotakis 2012-05-22 17:33:58 +00:00
parent f16f545c6e
commit 931146731d

@ -102,7 +102,7 @@ static GPUBufferPool *gpu_buffer_pool_new(void)
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 *GPU_buffer_alloc(int size)
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,