diff --git a/Userland/Libraries/LibGfx/ICC/BinaryFormat.h b/Userland/Libraries/LibGfx/ICC/BinaryFormat.h index 83fc0a69b8..f4a3bd3442 100644 --- a/Userland/Libraries/LibGfx/ICC/BinaryFormat.h +++ b/Userland/Libraries/LibGfx/ICC/BinaryFormat.h @@ -130,4 +130,13 @@ struct CLUTHeader { }; static_assert(AssertSize()); +// ICC v4, 10.15 multiLocalizedUnicodeType +struct MultiLocalizedUnicodeRawRecord { + BigEndian language_code; + BigEndian country_code; + BigEndian string_length_in_bytes; + BigEndian string_offset_in_bytes; +}; +static_assert(AssertSize()); + } diff --git a/Userland/Libraries/LibGfx/ICC/TagTypes.cpp b/Userland/Libraries/LibGfx/ICC/TagTypes.cpp index 0f92fc189f..57d64bbe45 100644 --- a/Userland/Libraries/LibGfx/ICC/TagTypes.cpp +++ b/Userland/Libraries/LibGfx/ICC/TagTypes.cpp @@ -686,7 +686,7 @@ ErrorOr> MultiLocalizedUnicodeTagDat // of each record. Any code that needs to access the nth record should determine the record’s offset by multiplying // n by the contents of this size field and adding 16. This minor extra effort allows for future expansion of the record // encoding, should the need arise, without having to define a new tag type." - if (record_size < 12) + if (record_size < sizeof(MultiLocalizedUnicodeRawRecord)) return Error::from_string_literal("ICC::Profile: multiLocalizedUnicodeType record size too small"); if (bytes.size() < 16 + number_of_records * record_size) return Error::from_string_literal("ICC::Profile: multiLocalizedUnicodeType not enough data for records"); @@ -699,17 +699,9 @@ ErrorOr> MultiLocalizedUnicodeTagDat // and should not be NULL terminated." auto& utf_16be_decoder = *TextCodec::decoder_for("utf-16be"sv); - struct RawRecord { - BigEndian language_code; - BigEndian country_code; - BigEndian string_length_in_bytes; - BigEndian string_offset_in_bytes; - }; - static_assert(AssertSize()); - for (u32 i = 0; i < number_of_records; ++i) { size_t offset = 16 + i * record_size; - RawRecord record = *bit_cast(bytes.data() + offset); + auto record = *bit_cast(bytes.data() + offset); records[i].iso_639_1_language_code = record.language_code; records[i].iso_3166_1_country_code = record.country_code;