mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +00:00
Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe
This commit is contained in:
parent
3a9f00c59b
commit
97e97bccab
105 changed files with 629 additions and 290 deletions
|
@ -84,7 +84,12 @@ int main(int argc, char** argv)
|
|||
args_parser.add_positional_argument(target, "Target device/file path", "target");
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
auto buffer = AK::ByteBuffer::create_zeroed(block_size);
|
||||
auto buffer_result = AK::ByteBuffer::create_zeroed(block_size);
|
||||
if (!buffer_result.has_value()) {
|
||||
warnln("Failed to allocate a buffer of {} bytes", block_size);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
auto buffer = buffer_result.release_value();
|
||||
|
||||
int fd = open(target, O_CREAT | O_RDWR, 0666);
|
||||
if (fd < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue