1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 09:47:34 +00:00

Everywhere: Use OOM-safe ByteBuffer APIs where possible

If we can easily communicate failure, let's avoid asserting and report
failure instead.
This commit is contained in:
Ali Mohammad Pur 2021-09-06 03:28:46 +04:30 committed by Andreas Kling
parent 6606993432
commit 3a9f00c59b
22 changed files with 135 additions and 67 deletions

View file

@ -122,7 +122,8 @@ private:
{
if (!m_condition()) {
write_to_buffer:;
m_buffer.append(bytes.data(), bytes.size());
if (!m_buffer.try_append(bytes.data(), bytes.size()))
return 0;
return bytes.size();
}

View file

@ -165,8 +165,9 @@ static void tls(const char* message, size_t len)
g_loop.quit(0);
};
}
write.append(message, len);
write.append("\r\n", 2);
auto ok = write.try_append(message, len);
ok = ok && write.try_append("\r\n", 2);
VERIFY(ok);
}
static void aes_cbc(const char* message, size_t len)
@ -2037,7 +2038,10 @@ static void tls_test_client_hello()
loop.quit(1);
} else {
// print_buffer(data.value(), 16);
contents.append(data.value().data(), data.value().size());
if (!contents.try_append(data.value().data(), data.value().size())) {
FAIL(Allocation failed);
loop.quit(1);
}
}
};
tls->on_tls_finished = [&] {