From 316291a9d374da768c8b629d2f04ed18015a3608 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Tue, 24 Oct 2023 21:40:05 +0200 Subject: [PATCH] fix integer underflow (#1010) --- libheif/box.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libheif/box.cc b/libheif/box.cc index e015ca751d..4c0a85afe4 100644 --- a/libheif/box.cc +++ b/libheif/box.cc @@ -653,7 +653,7 @@ Error Box::read(BitstreamRange& range, std::shared_ptr* result) } int64_t box_size = static_cast(hdr.get_box_size()); - int64_t box_size_without_header = box_size - hdr.get_header_size(); + int64_t box_size_without_header = hdr.has_fixed_box_size() ? (box_size - hdr.get_header_size()) : (int64_t)range.get_remaining_bytes(); // Box size may not be larger than remaining bytes in parent box.