Commit 388d4b35 for libheif

commit 388d4b35697cb06e18a36d24fea9da83fdc42fee
Author: Dirk Farin <dirk.farin@gmail.com>
Date:   Sat Nov 29 22:51:36 2025 +0100

    fix invalid read during color-conversion when alpha image bpp differs from main image (#1626)

diff --git a/libheif/color-conversion/yuv2rgb.cc b/libheif/color-conversion/yuv2rgb.cc
index f93f3c23..a883e68f 100644
--- a/libheif/color-conversion/yuv2rgb.cc
+++ b/libheif/color-conversion/yuv2rgb.cc
@@ -611,6 +611,23 @@ Op_YCbCr420_to_RRGGBBaa::convert_colorspace(const std::shared_ptr<const HeifPixe
   }

   if (has_alpha) {
+    if (input->get_width(heif_channel_Alpha) != width ||
+        input->get_height(heif_channel_Alpha) != height) {
+      return Error{
+        heif_error_Unsupported_feature,
+        heif_suberror_Unspecified,
+        "Color conversion cannot handle alpha images with sizes differing from the main image size."
+      };
+    }
+
+    if (input->get_bits_per_pixel(heif_channel_Alpha) != bpp) {
+      return Error{
+        heif_error_Unsupported_feature,
+        heif_suberror_Unspecified,
+        "Color conversion cannot handle alpha images with bits-per-pixel differing from the main image."
+      };
+    }
+
     if (auto err = outimg->add_plane(heif_channel_Alpha, width, height, bpp, limits)) {
       return err;
     }