Commit 271d6ca5 for libheif
commit 271d6ca590c7e1f00cd2fd0414d91b68f83dd4b6
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Fri Dec 26 15:07:41 2025 +0100
regions: check for zero size mask image
diff --git a/libheif/color-conversion/colorconversion.cc b/libheif/color-conversion/colorconversion.cc
index 5a4d467a..8ffbd51f 100644
--- a/libheif/color-conversion/colorconversion.cc
+++ b/libheif/color-conversion/colorconversion.cc
@@ -46,7 +46,7 @@
#endif
-#define DEBUG_ME 0
+#define DEBUG_ME 1
#define DEBUG_PIPELINE_CREATION 0
#define USE_CENTER_CHROMA_422 0
diff --git a/libheif/color-conversion/yuv2rgb.cc b/libheif/color-conversion/yuv2rgb.cc
index a883e68f..9abd5796 100644
--- a/libheif/color-conversion/yuv2rgb.cc
+++ b/libheif/color-conversion/yuv2rgb.cc
@@ -49,7 +49,7 @@ Op_YCbCr_to_RGB<Pixel>::state_after_conversion(const ColorState& input_state,
}
int matrix = input_state.nclx.get_matrix_coefficients();
- if ( matrix == 11 || matrix == 14) {
+ if (matrix == 11 || matrix == 14) {
return {};
}
@@ -236,6 +236,9 @@ Op_YCbCr_to_RGB<Pixel>::convert_colorspace(const std::shared_ptr<const HeifPixel
out_r[y * out_r_stride + x] = (Pixel) (clip_int_u8(yv - cb + cr));
out_g[y * out_g_stride + x] = (Pixel) (clip_int_u8(yv + cb));
out_b[y * out_b_stride + x] = (Pixel) (clip_int_u8(yv - cb - cr));
+ }
+ else if (matrix_coeffs == 16) {
+
}
else { // TODO: matrix_coefficients = 11,14
float yv, cb, cr;
diff --git a/libheif/region.cc b/libheif/region.cc
index 092d060c..fc282fbf 100644
--- a/libheif/region.cc
+++ b/libheif/region.cc
@@ -450,6 +450,14 @@ Error RegionGeometry_InlineMask::parse(const std::vector<uint8_t>& data,
"Deflate compressed inline mask is not yet supported");
}
+ if (width==0 || height==0) {
+ return {
+ heif_error_Invalid_input,
+ heif_suberror_Unspecified,
+ "Zero size mask image."
+ };
+ }
+
if (width / 8 + 1 > UINT32_MAX / height) {
return {
heif_error_Memory_allocation_error,