Skip to content

Commit

Permalink
uncompressed: fix component type validity check
Browse files Browse the repository at this point in the history
  • Loading branch information
bradh committed Nov 9, 2023
1 parent 82797ad commit 13af0eb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libheif/uncompressed_image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ enum heif_uncompressed_component_type
component_type_cyan = 13,
component_type_magenta = 14,
component_type_yellow = 15,
component_type_key_black = 16
component_type_key_black = 16,
component_type_max_valid = component_type_key_black
};

bool is_predefined_component_type(uint16_t type)
Expand Down Expand Up @@ -467,8 +468,10 @@ static Error get_heif_chroma_uncompressed(std::shared_ptr<Box_uncC>& uncC, std::
uint16_t component_index = component.component_index;
uint16_t component_type = cmpd->get_components()[component_index].component_type;

if (component_type >= 16) {
return { heif_error_Unsupported_feature, heif_suberror_Invalid_parameter_value, "a component_type >= 16 is not supported"};
if (component_type > component_type_max_valid) {
std::stringstream sstr;
sstr << "a component_type > " << component_type_max_valid << " is not supported";
return { heif_error_Unsupported_feature, heif_suberror_Invalid_parameter_value, sstr.str()};
}

componentSet |= (1 << component_type);
Expand Down

0 comments on commit 13af0eb

Please sign in to comment.