mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-30 16:28:48 +00:00
Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe
This commit is contained in:
parent
3a9f00c59b
commit
97e97bccab
Notes:
sideshowbarker
2024-07-18 04:39:40 +09:00
Author: https://github.com/alimpfard
Commit: 97e97bccab
Pull-request: https://github.com/SerenityOS/serenity/pull/9832
Reviewed-by: https://github.com/IdanHo
105 changed files with 629 additions and 290 deletions
|
@ -58,7 +58,8 @@ Result<NonnullOwnPtr<GUIDPartitionTable>, PartitionTable::Error> GUIDPartitionTa
|
|||
GUIDPartitionTable::GUIDPartitionTable(const StorageDevice& device)
|
||||
: MBRPartitionTable(device)
|
||||
{
|
||||
m_cached_header = ByteBuffer::create_zeroed(m_device->block_size());
|
||||
// FIXME: Handle OOM failure here.
|
||||
m_cached_header = ByteBuffer::create_zeroed(m_device->block_size()).release_value();
|
||||
VERIFY(partitions_count() == 0);
|
||||
if (!initialize())
|
||||
m_valid = false;
|
||||
|
@ -87,7 +88,12 @@ bool GUIDPartitionTable::initialize()
|
|||
return false;
|
||||
}
|
||||
|
||||
auto entries_buffer = ByteBuffer::create_zeroed(m_device->block_size());
|
||||
auto entries_buffer_result = ByteBuffer::create_zeroed(m_device->block_size());
|
||||
if (!entries_buffer_result.has_value()) {
|
||||
dbgln("GUIPartitionTable: not enough memory for entries buffer");
|
||||
return false;
|
||||
}
|
||||
auto entries_buffer = entries_buffer_result.release_value();
|
||||
auto raw_entries_buffer = UserOrKernelBuffer::for_kernel_buffer(entries_buffer.data());
|
||||
size_t raw_byte_index = header().partition_array_start_lba * m_device->block_size();
|
||||
for (size_t entry_index = 0; entry_index < header().entries_count; entry_index++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue