Skip to content

Commit

Permalink
Fix excessive memory usage when saving EXR file with many channels (A…
Browse files Browse the repository at this point in the history
…cademySoftwareFoundation#3176)

Scratch memory allocation in ImageOutput::to_native_rectangle was using
the number of channels squared.
  • Loading branch information
brechtvl authored and lgritz committed Nov 11, 2021
1 parent 2dd84e1 commit 7922921
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libOpenImageIO/imageoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ ImageOutput::to_native_rectangle(int xbegin, int xend, int ybegin, int yend,
// (cases #3 and #4 above).
imagesize_t contiguoussize = contiguous
? 0
: rectangle_values * input_pixel_bytes;
: rectangle_pixels * input_pixel_bytes;
contiguoussize = (contiguoussize + 3)
& (~3); // Round up to 4-byte boundary
OIIO_DASSERT((contiguoussize & 3) == 0);
Expand Down

0 comments on commit 7922921

Please sign in to comment.