diff --git a/cocos/renderer/CCCustomCommand.cpp b/cocos/renderer/CCCustomCommand.cpp index f1c57d4d1c..e06012a17e 100644 --- a/cocos/renderer/CCCustomCommand.cpp +++ b/cocos/renderer/CCCustomCommand.cpp @@ -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);