Skip to content

Commit

Permalink
uncompressed: show numeric component ID when there is no name known (…
Browse files Browse the repository at this point in the history
…Clusterfuzz Issue 63040)
  • Loading branch information
farindk committed Oct 13, 2023
1 parent e2f0c38 commit 7e4aacb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion libheif/uncompressed_image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ enum heif_uncompressed_component_type
component_type_key_black = 16
};

bool is_predefined_component_type(uint16_t type)
{
// check whether the component type can be mapped to heif_uncompressed_component_type and we have a name defined for
// it in sNames_uncompressed_component_type.
return (type >= 0 && type <= 16);
}

static std::map<heif_uncompressed_component_type, const char*> sNames_uncompressed_component_type{
{component_type_monochrome, "monochrome"},
{component_type_Y, "Y"},
Expand Down Expand Up @@ -156,7 +163,14 @@ std::string Box_cmpd::dump(Indent& indent) const
sstr << Box::dump(indent);

for (const auto& component : m_components) {
sstr << indent << "component_type: " << get_name(heif_uncompressed_component_type(component.component_type), sNames_uncompressed_component_type) << "\n";
sstr << indent << "component_type: ";
if (is_predefined_component_type(component.component_type)) {
sstr << get_name(heif_uncompressed_component_type(component.component_type), sNames_uncompressed_component_type) << "\n";
}
else {
sstr << "0x" << std::hex << component.component_type << std::dec << "\n";
}

if (component.component_type >= 0x8000) {
sstr << indent << "| component_type_uri: " << component.component_type_uri << "\n";
}
Expand Down

0 comments on commit 7e4aacb

Please sign in to comment.