diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-09-06 03:29:52 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-06 01:53:26 +0200 |
commit | 97e97bccab085823d1365cb54142fd8c41dbcd8c (patch) | |
tree | 9008687dbcdfb6f36f6dc6372aa382b15b9d36c8 /Tests/Kernel | |
parent | 3a9f00c59bad7735970c72cb940d08161fda09b0 (diff) | |
download | serenity-97e97bccab085823d1365cb54142fd8c41dbcd8c.zip |
Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe
Diffstat (limited to 'Tests/Kernel')
-rw-r--r-- | Tests/Kernel/stress-writeread.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Tests/Kernel/stress-writeread.cpp b/Tests/Kernel/stress-writeread.cpp index 8151c355d1..62cc02ada7 100644 --- a/Tests/Kernel/stress-writeread.cpp +++ b/Tests/Kernel/stress-writeread.cpp @@ -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) { |