Commit 177ff930 for libheif

commit 177ff930a5eed0c556a32980caaae69b81689433
Author: Dirk Farin <dirk.farin@gmail.com>
Date:   Thu Aug 27 00:38:02 2026 +0200

    fix the remaining clang-tidy 18 findings

    - bitstream.h: default member initializer for StreamReader_memory::m_position
      (modernize-use-default-member-init).
    - encoder_aom.cc: the cast of a flag combination to aom_img_fmt_t is
      intentional; mark it for clang-analyzer-optin.core.EnumCastOutOfRange.
    - error.h: the analyzer reports a garbage value assigned in the implicit
      copy constructor of Error when it is copied out of the std::variant in
      Result<T>. All members have default initializers, so this is a false
      positive of the variant modeling; suppress it on the class.

diff --git a/libheif/bitstream.cc b/libheif/bitstream.cc
index d061c616..57d617af 100644
--- a/libheif/bitstream.cc
+++ b/libheif/bitstream.cc
@@ -75,8 +75,7 @@ bool StreamReader_istream::seek(uint64_t position)


 StreamReader_memory::StreamReader_memory(const uint8_t* data, size_t size, bool copy)
-    : m_length(size),
-      m_position(0)
+    : m_length(size)
 {
   if (copy) {
     m_owned_data = new uint8_t[m_length];
diff --git a/libheif/bitstream.h b/libheif/bitstream.h
index fb31316e..a56ebf9d 100644
--- a/libheif/bitstream.h
+++ b/libheif/bitstream.h
@@ -143,7 +143,7 @@ public:
 private:
   const uint8_t* m_data;
   uint64_t m_length;
-  uint64_t m_position;
+  uint64_t m_position = 0;

   // if we made a copy of the data, we store a pointer to the owned memory area here
   uint8_t* m_owned_data = nullptr;
diff --git a/libheif/error.h b/libheif/error.h
index c66e5a1e..607605e0 100644
--- a/libheif/error.h
+++ b/libheif/error.h
@@ -74,7 +74,10 @@ private:
 };


-class Error
+// The clang static analyzer reports a garbage value assigned in the implicit copy constructor
+// when an Error is copied out of the std::variant inside Result<T>. All members have default
+// initializers, so this is a false positive of its variant modeling.
+class Error // NOLINT(clang-analyzer-core.uninitialized.Assign)
 {
 public:
   heif_error_code error_code = heif_error_Ok;
diff --git a/libheif/plugins/encoder_aom.cc b/libheif/plugins/encoder_aom.cc
index 0dfe8f7e..7755e9df 100644
--- a/libheif/plugins/encoder_aom.cc
+++ b/libheif/plugins/encoder_aom.cc
@@ -896,7 +896,8 @@ chroma_info get_chroma_info(heif_chroma chroma,
   }

   if (bpp_y > 8) {
-    info.img_format = (aom_img_fmt_t) (info.img_format | AOM_IMG_FMT_HIGHBITDEPTH);
+    // aom_img_fmt_t is a set of flags, so the combined value is intentionally not an enumerator.
+    info.img_format = (aom_img_fmt_t) (info.img_format | AOM_IMG_FMT_HIGHBITDEPTH); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange)
   }

   return info;