From 52e88e89542cfd3e6e87ca10ebc70ae1048b2890 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Fri, 29 Mar 2024 15:16:55 +0100 Subject: [PATCH] imageio: fix issues/crash on png with transparency If a png has a transparency chunk (tRNS), after converting the transparency to alpha we should also strip alpha (color_type is not updated with PNG_COLOR_MASK_ALPHA flag set) or the row parsing will return also the alpha channel causing a memory overflow. --- rtengine/imageio.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/rtengine/imageio.cc b/rtengine/imageio.cc index e2c6c1310..f096213dc 100644 --- a/rtengine/imageio.cc +++ b/rtengine/imageio.cc @@ -285,6 +285,7 @@ int ImageIO::loadPNG (const Glib::ustring &fname) if (png_get_valid(png, info, PNG_INFO_tRNS)) { png_set_tRNS_to_alpha(png); + png_set_strip_alpha(png); } if (color_type & PNG_COLOR_MASK_ALPHA) {