Fix memory leak when saving OpenEXR half file fails.

This commit is contained in:
Brecht Van Lommel 2016-02-20 15:48:15 +01:00
parent 4dd406c7b7
commit 95180a46ed
1 changed files with 2 additions and 4 deletions

View File

@ -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)
{