mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 15:16:14 +00:00
Kernel: Make it possible for KBufferBuilder creation to fail
This patch adds KBufferBuilder::try_create() and treats it like anything else that can fail. And so, failure to allocate the initial internal buffer of the builder will now propagate an ENOMEM to the caller. :^)
This commit is contained in:
@@ -575,7 +575,12 @@ bool Process::dump_perfcore()
|
||||
}
|
||||
|
||||
auto& description = *description_or_error.value();
|
||||
KBufferBuilder builder;
|
||||
auto builder_or_error = KBufferBuilder::try_create();
|
||||
if (builder_or_error.is_error()) {
|
||||
dbgln("Failed to generate perfcore for pid {}: Could not allocate KBufferBuilder.", pid());
|
||||
return false;
|
||||
}
|
||||
auto builder = builder_or_error.release_value();
|
||||
if (!m_perf_event_buffer->to_json(builder)) {
|
||||
dbgln("Failed to generate perfcore for pid {}: Could not serialize performance events to JSON.", pid().value());
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user