diff options
author | Nico Weber <thakis@chromium.org> | 2023-01-23 18:21:36 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-24 14:45:27 +0000 |
commit | f7f592f5d31434ae065e99b14116e5d50c82592a (patch) | |
tree | a4c45759536aa81bc7a1b2c2255346c4726989d4 /Userland | |
parent | a19e54c1db30984a4d627f54808a5f6b6193349b (diff) | |
download | serenity-f7f592f5d31434ae065e99b14116e5d50c82592a.zip |
LibGfx: Pass offset and size instead of full TagTableEntry to read_tag
read_tag() has no business knowing the tag signature.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGfx/ICCProfile.cpp | 24 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/ICCProfile.h | 2 |
2 files changed, 13 insertions, 13 deletions
diff --git a/Userland/Libraries/LibGfx/ICCProfile.cpp b/Userland/Libraries/LibGfx/ICCProfile.cpp index aae119683e..92aa0a54f6 100644 --- a/Userland/Libraries/LibGfx/ICCProfile.cpp +++ b/Userland/Libraries/LibGfx/ICCProfile.cpp @@ -919,12 +919,12 @@ ErrorOr<void> Profile::read_header(ReadonlyBytes bytes) return {}; } -ErrorOr<NonnullRefPtr<TagData>> Profile::read_tag(ReadonlyBytes bytes, Detail::TagTableEntry const& entry) +ErrorOr<NonnullRefPtr<TagData>> Profile::read_tag(ReadonlyBytes bytes, u32 offset_to_beginning_of_tag_data_element, u32 size_of_tag_data_element) { - if (entry.offset_to_beginning_of_tag_data_element + entry.size_of_tag_data_element > bytes.size()) + if (offset_to_beginning_of_tag_data_element + size_of_tag_data_element > bytes.size()) return Error::from_string_literal("ICC::Profile: Tag data out of bounds"); - auto tag_bytes = bytes.slice(entry.offset_to_beginning_of_tag_data_element, entry.size_of_tag_data_element); + auto tag_bytes = bytes.slice(offset_to_beginning_of_tag_data_element, size_of_tag_data_element); // ICC v4, 9 Tag definitions // ICC v4, 9.1 General @@ -936,22 +936,22 @@ ErrorOr<NonnullRefPtr<TagData>> Profile::read_tag(ReadonlyBytes bytes, Detail::T auto type = tag_type(tag_bytes); switch (type) { case CurveTagData::Type: - return CurveTagData::from_bytes(tag_bytes, entry.offset_to_beginning_of_tag_data_element, entry.size_of_tag_data_element); + return CurveTagData::from_bytes(tag_bytes, offset_to_beginning_of_tag_data_element, size_of_tag_data_element); case MultiLocalizedUnicodeTagData::Type: - return MultiLocalizedUnicodeTagData::from_bytes(tag_bytes, entry.offset_to_beginning_of_tag_data_element, entry.size_of_tag_data_element); + return MultiLocalizedUnicodeTagData::from_bytes(tag_bytes, offset_to_beginning_of_tag_data_element, size_of_tag_data_element); case ParametricCurveTagData::Type: - return ParametricCurveTagData::from_bytes(tag_bytes, entry.offset_to_beginning_of_tag_data_element, entry.size_of_tag_data_element); + return ParametricCurveTagData::from_bytes(tag_bytes, offset_to_beginning_of_tag_data_element, size_of_tag_data_element); case S15Fixed16ArrayTagData::Type: - return S15Fixed16ArrayTagData::from_bytes(tag_bytes, entry.offset_to_beginning_of_tag_data_element, entry.size_of_tag_data_element); + return S15Fixed16ArrayTagData::from_bytes(tag_bytes, offset_to_beginning_of_tag_data_element, size_of_tag_data_element); case TextDescriptionTagData::Type: - return TextDescriptionTagData::from_bytes(tag_bytes, entry.offset_to_beginning_of_tag_data_element, entry.size_of_tag_data_element); + return TextDescriptionTagData::from_bytes(tag_bytes, offset_to_beginning_of_tag_data_element, size_of_tag_data_element); case TextTagData::Type: - return TextTagData::from_bytes(tag_bytes, entry.offset_to_beginning_of_tag_data_element, entry.size_of_tag_data_element); + return TextTagData::from_bytes(tag_bytes, offset_to_beginning_of_tag_data_element, size_of_tag_data_element); case XYZTagData::Type: - return XYZTagData::from_bytes(tag_bytes, entry.offset_to_beginning_of_tag_data_element, entry.size_of_tag_data_element); + return XYZTagData::from_bytes(tag_bytes, offset_to_beginning_of_tag_data_element, size_of_tag_data_element); default: // FIXME: optionally ignore tags of unknown type - return adopt_ref(*new UnknownTagData(entry.offset_to_beginning_of_tag_data_element, entry.size_of_tag_data_element, type)); + return adopt_ref(*new UnknownTagData(offset_to_beginning_of_tag_data_element, size_of_tag_data_element, type)); } } @@ -991,7 +991,7 @@ ErrorOr<void> Profile::read_tag_table(ReadonlyBytes bytes) for (u32 i = 0; i < tag_count; ++i) { // FIXME: optionally ignore tags with unknown signature // FIXME: dedupe identical offset/sizes - auto tag_data = TRY(read_tag(bytes, tag_table_entries[i])); + auto tag_data = TRY(read_tag(bytes, tag_table_entries[i].offset_to_beginning_of_tag_data_element, tag_table_entries[i].size_of_tag_data_element)); // "Duplicate tag signatures shall not be included in the tag table." if (TRY(m_tag_table.try_set(tag_table_entries[i].tag_signature, move(tag_data))) != AK::HashSetResult::InsertedNewEntry) return Error::from_string_literal("ICC::Profile: duplicate tag signature"); diff --git a/Userland/Libraries/LibGfx/ICCProfile.h b/Userland/Libraries/LibGfx/ICCProfile.h index c56c0f3d3b..fb8296d34f 100644 --- a/Userland/Libraries/LibGfx/ICCProfile.h +++ b/Userland/Libraries/LibGfx/ICCProfile.h @@ -534,7 +534,7 @@ public: private: ErrorOr<void> read_header(ReadonlyBytes); - ErrorOr<NonnullRefPtr<TagData>> read_tag(ReadonlyBytes, Detail::TagTableEntry const&); + ErrorOr<NonnullRefPtr<TagData>> read_tag(ReadonlyBytes bytes, u32 offset_to_beginning_of_tag_data_element, u32 size_of_tag_data_element); ErrorOr<void> read_tag_table(ReadonlyBytes); u32 m_on_disk_size { 0 }; |