Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: properties build fix #1261

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions libheif/api/libheif/heif_properties.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ static struct heif_error find_property(const struct heif_context* context,

auto box = properties[propertyId - 1];
*box_other = std::dynamic_pointer_cast<Box_other>(box);

// TODO: every Box (not just Box_other) should have a get_raw_data() method.
if (*box_other == nullptr) {
return {heif_error_Usage_error, heif_suberror_Invalid_property, "this property is not read as a raw box"};
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not make find_property() specific only for Box_other.

return heif_error_success;
}

Expand All @@ -371,18 +377,6 @@ struct heif_error heif_item_get_property_raw_size(const struct heif_context* con
return err;
}

if (propertyId < 1 || propertyId - 1 >= properties.size()) {
return {heif_error_Usage_error, heif_suberror_Invalid_property, "property index out of range"};
}

auto box = properties[propertyId - 1];
auto box_other = std::dynamic_pointer_cast<Box_other>(box);

// TODO: every Box (not just Box_other) should have a get_raw_data() method.
if (box_other == nullptr) {
return {heif_error_Usage_error, heif_suberror_Invalid_property, "this property is not read as a raw box"};
}

auto data = box_other->get_raw_data();

*size_out = data.size();
Expand All @@ -406,14 +400,8 @@ struct heif_error heif_item_get_property_raw_data(const struct heif_context* con
return err;
}

// TODO: every Box (not just Box_other) should have a get_raw_data() method.
if (box_other == nullptr) {
return {heif_error_Usage_error, heif_suberror_Invalid_property, "this property is not read as a raw box"};
}

auto data = box_other->get_raw_data();


std::copy(data.begin(), data.end(), data_out);

return heif_error_success;
Expand All @@ -434,10 +422,6 @@ struct heif_error heif_item_get_property_uuid_type(const struct heif_context* co
return err;
}

if (box_other == nullptr) {
return {heif_error_Usage_error, heif_suberror_Invalid_property, "this property is not read as a raw box"};
}

auto uuid = box_other->get_uuid_type();

std::copy(uuid.begin(), uuid.end(), extended_type);
Expand Down
Loading