[Bf-blender-cvs] [95180a4] master: Fix memory leak when saving OpenEXR half file fails.
Brecht Van Lommel
noreply at git.blender.org
Sat Feb 20 17:57:09 CET 2016
Commit: 95180a46ed019205c7bb7449e1d92010fe172316
Author: Brecht Van Lommel
Date: Sat Feb 20 15:48:15 2016 +0100
Branches: master
https://developer.blender.org/rB95180a46ed019205c7bb7449e1d92010fe172316
Fix memory leak when saving OpenEXR half file fails.
===================================================================
M source/blender/imbuf/intern/openexr/openexr_api.cpp
===================================================================
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 40b5a1a..47fa4c1 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -422,14 +422,14 @@ static bool imb_save_openexr_half(
OutputFile file(file_stream, header);
/* we store first everything in half array */
- RGBAZ *pixels = new RGBAZ[height * width * totviews];
+ std::vector<RGBAZ> pixels(height * width * totviews);
int xstride = sizeof(RGBAZ);
int ystride = xstride * width;
for (view_id = 0; view_id < totviews; view_id ++) {
ImBuf *view_ibuf = is_multiview ? getbuffer(ibuf->userdata, view_id) : ibuf;
const size_t offset = view_id * width * height;
- RGBAZ *to = pixels + offset;
+ RGBAZ *to = &pixels[offset];
/* TODO (dfelinto)
* In some cases we get NULL ibufs, it needs investigation, meanwhile prevent crash
@@ -487,8 +487,6 @@ static bool imb_save_openexr_half(
file.setFrameBuffer(frameBuffer);
file.writePixels(height);
-
- delete[] pixels;
}
catch (const std::exception& exc)
{
More information about the Bf-blender-cvs
mailing list