From 61b14bf86c27e3a0c7b8bd707f5aa2aa56282163 Mon Sep 17 00:00:00 2001 From: HALX99 Date: Mon, 30 Mar 2020 14:54:13 +0800 Subject: [PATCH] fix memory leak & correct indent --- cocos/renderer/backend/opengl/TextureGL.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cocos/renderer/backend/opengl/TextureGL.cpp b/cocos/renderer/backend/opengl/TextureGL.cpp index cdbd7fada1..ddf14ac197 100644 --- a/cocos/renderer/backend/opengl/TextureGL.cpp +++ b/cocos/renderer/backend/opengl/TextureGL.cpp @@ -332,11 +332,13 @@ void Texture2DGL::getBytes(std::size_t x, std::size_t y, std::size_t width, std: } callback(flippedImage, width, height); CC_SAFE_DELETE_ARRAY(flippedImage); - } else - { - callback(image, width, height); - CC_SAFE_DELETE_ARRAY(image); } + else + { + callback(image, width, height); + } + + CC_SAFE_DELETE_ARRAY(image); glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); glDeleteFramebuffers(1, &frameBuffer); @@ -425,11 +427,12 @@ void TextureCubeGL::getBytes(std::size_t x, std::size_t y, std::size_t width, st } callback(flippedImage, width, height); CC_SAFE_DELETE_ARRAY(flippedImage); - } else + } + else { callback(image, width, height); - CC_SAFE_DELETE_ARRAY(image); } + CC_SAFE_DELETE_ARRAY(image); glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); glDeleteFramebuffers(1, &frameBuffer);