fix memory leak issue (#20440)

This commit is contained in:
coulsonwang 2020-01-08 10:05:49 +08:00 committed by halx99
parent 71da768d3c
commit 8c8280c7d6
1 changed files with 2 additions and 0 deletions

View File

@ -102,6 +102,7 @@ void CustomCommand::setVertexBuffer(backend::Buffer *vertexBuffer)
if (_vertexBuffer == vertexBuffer)
return;
CC_SAFE_RELEASE(_vertexBuffer);
_vertexBuffer = vertexBuffer;
CC_SAFE_RETAIN(_vertexBuffer);
}
@ -111,6 +112,7 @@ void CustomCommand::setIndexBuffer(backend::Buffer *indexBuffer, IndexFormat for
if (_indexBuffer == indexBuffer && _indexFormat == format)
return;
CC_SAFE_RELEASE(_indexBuffer);
_indexBuffer = indexBuffer;
CC_SAFE_RETAIN(_indexBuffer);