Commit 6721f307 for libheif

commit 6721f307ad684804b735e917dde7d372c5faae31
Author: Dirk Farin <dirk.farin@gmail.com>
Date:   Mon May 18 18:03:01 2026 +0200

    fix integer overflow when computing chroma sizes

diff --git a/libheif/image/pixelimage.cc b/libheif/image/pixelimage.cc
index a824182c..4ea2487b 100644
--- a/libheif/image/pixelimage.cc
+++ b/libheif/image/pixelimage.cc
@@ -57,7 +57,7 @@ uint32_t chroma_width(uint32_t w, heif_chroma chroma)
   switch (chroma) {
     case heif_chroma_420:
     case heif_chroma_422:
-      return (w+1)/2;
+      return w/2 + (w & 1); // note: prevents integer overflow
     default:
       return w;
   }
@@ -67,7 +67,7 @@ uint32_t chroma_height(uint32_t h, heif_chroma chroma)
 {
   switch (chroma) {
     case heif_chroma_420:
-      return (h+1)/2;
+      return h/2 + (h & 1); // note: prevents integer overflow
     default:
       return h;
   }