1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:17:35 +00:00

LibGfx: Make ICC code handle out-of-memory situations better

...by using adopt_nonnull_ref_or_enomem() via the try_make_ref_counted()
wrapper, instead of adopt_ref().
This commit is contained in:
Nico Weber 2023-02-10 19:27:32 -05:00 committed by Jelle Raaijmakers
parent f09d2ae395
commit cf73e15dc1
2 changed files with 27 additions and 27 deletions

View file

@ -608,7 +608,7 @@ ErrorOr<NonnullRefPtr<TagData>> Profile::read_tag(ReadonlyBytes bytes, u32 offse
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(offset_to_beginning_of_tag_data_element, size_of_tag_data_element, type));
return try_make_ref_counted<UnknownTagData>(offset_to_beginning_of_tag_data_element, size_of_tag_data_element, type);
}
}
@ -1314,7 +1314,7 @@ ErrorOr<void> Profile::check_tag_types()
ErrorOr<NonnullRefPtr<Profile>> Profile::try_load_from_externally_owned_memory(ReadonlyBytes bytes)
{
auto profile = adopt_ref(*new Profile());
auto profile = TRY(try_make_ref_counted<Profile>());
TRY(profile->read_header(bytes));
bytes = bytes.trim(profile->on_disk_size());
TRY(profile->read_tag_table(bytes));