Commit b65b0440 for libheif

commit b65b0440c31c7d966dd176f39dea2efa3dd198c5
Author: Dirk Farin <dirk.farin@gmail.com>
Date:   Fri May 15 01:20:50 2026 +0200

    Reject non-8-bit RGBA in extract_alpha_from_RGBA

diff --git a/libheif/image/pixelimage.cc b/libheif/image/pixelimage.cc
index 5f1cdbb9..4d6da98b 100644
--- a/libheif/image/pixelimage.cc
+++ b/libheif/image/pixelimage.cc
@@ -905,6 +905,15 @@ Error HeifPixelImage::extract_alpha_from_RGBA(const std::shared_ptr<const HeifPi
   uint32_t width = src_image->get_width();
   uint32_t height = src_image->get_height();

+  // The copy loop below assumes 8-bit interleaved RGBA (4 bytes per pixel,
+  // alpha at byte offset 3). 16-bit interleaved formats (RRGGBBAA_*) have a
+  // different layout and would be read/written incorrectly.
+  if (src_image->get_bits_per_pixel(heif_channel_interleaved) != 8) {
+    return {heif_error_Unsupported_feature,
+            heif_suberror_Unspecified,
+            "extract_alpha_from_RGBA only supports 8-bit interleaved RGBA"};
+  }
+
   if (Error err = add_channel(heif_channel_Y, width, height, src_image->get_bits_per_pixel(heif_channel_interleaved), limits)) {
     return err;
   }