fix memory leak & correct indent

This commit is contained in:
HALX99 2020-03-30 14:54:13 +08:00 committed by GitHub
parent 5fd1bc7da7
commit 61b14bf86c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -332,11 +332,13 @@ void Texture2DGL::getBytes(std::size_t x, std::size_t y, std::size_t width, std:
} }
callback(flippedImage, width, height); callback(flippedImage, width, height);
CC_SAFE_DELETE_ARRAY(flippedImage); 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); glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
glDeleteFramebuffers(1, &frameBuffer); 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); callback(flippedImage, width, height);
CC_SAFE_DELETE_ARRAY(flippedImage); CC_SAFE_DELETE_ARRAY(flippedImage);
} else }
else
{ {
callback(image, width, height); callback(image, width, height);
CC_SAFE_DELETE_ARRAY(image);
} }
CC_SAFE_DELETE_ARRAY(image);
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
glDeleteFramebuffers(1, &frameBuffer); glDeleteFramebuffers(1, &frameBuffer);