Skip to content

Commit b385553

Browse files
committed
fix potential NULL-pointer deref in ImageItem_iden
1 parent 122fd47 commit b385553

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

libheif/image-items/iden.cc

+13
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ Error ImageItem_iden::get_coded_image_colorspace(heif_colorspace* out_colorspace
9090
}
9191

9292
auto image = get_context()->get_image(child, true);
93+
if (!image) {
94+
return Error{heif_error_Invalid_input,
95+
heif_suberror_Nonexisting_item_referenced};
96+
}
97+
9398
return image->get_coded_image_colorspace(out_colorspace, out_chroma);
9499
}
95100

@@ -103,6 +108,10 @@ int ImageItem_iden::get_luma_bits_per_pixel() const
103108
}
104109

105110
auto image = get_context()->get_image(child, true);
111+
if (!image) {
112+
return -1;
113+
}
114+
106115
return image->get_luma_bits_per_pixel();
107116
}
108117

@@ -116,5 +125,9 @@ int ImageItem_iden::get_chroma_bits_per_pixel() const
116125
}
117126

118127
auto image = get_context()->get_image(child, true);
128+
if (!image) {
129+
return -1;
130+
}
131+
119132
return image->get_chroma_bits_per_pixel();
120133
}

0 commit comments

Comments
 (0)