From b7c9239741d77b4d460ba9e0ef14fa37727ea933 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Tue, 12 Dec 2023 22:18:43 -0800 Subject: [PATCH] fix(png): Fix crash for writing large PNGs with alpha There was a flaw in PNGOutput::write_scanlines when the y range of scanlines to write consisted of less than the whole image, and alpha de-association was needed -- we used the whole-image size instead of the y range of scanlines size. Fixes PR 4044 Signed-off-by: Larry Gritz --- src/png.imageio/pngoutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/png.imageio/pngoutput.cpp b/src/png.imageio/pngoutput.cpp index cc694f5a37..f752ab7d03 100644 --- a/src/png.imageio/pngoutput.cpp +++ b/src/png.imageio/pngoutput.cpp @@ -385,7 +385,7 @@ PNGOutput::write_scanlines(int ybegin, int yend, int z, TypeDesc format, unassoc_scratch.reset(new float[nvals]); float* floatvals = unassoc_scratch.get(); // Contiguize and convert to float - OIIO::convert_image(m_spec.nchannels, m_spec.width, m_spec.height, 1, + OIIO::convert_image(m_spec.nchannels, m_spec.width, yend - ybegin, 1, data, format, xstride, ystride, AutoStride, floatvals, TypeFloat, AutoStride, AutoStride, AutoStride);