mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
ProcFS: Check for empty Optional in read_bytes()
In read_bytes() we now check that the Optional "data" actually contains a value before use, avoiding a failing asserting in kernel space.
This commit is contained in:
parent
4d99856f95
commit
d063734f69
Notes:
sideshowbarker
2024-07-19 11:34:50 +09:00
Author: https://github.com/DrewStratford Commit: https://github.com/SerenityOS/serenity/commit/d063734f699 Pull-request: https://github.com/SerenityOS/serenity/pull/681
@ -997,10 +997,14 @@ ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDes
|
||||
}
|
||||
|
||||
auto& data = generated_data;
|
||||
ssize_t nread = min(static_cast<off_t>(data.value().size() - offset), static_cast<off_t>(count));
|
||||
memcpy(buffer, data.value().data() + offset, nread);
|
||||
if (nread == 0 && description && description->generator_cache())
|
||||
description->generator_cache().clear();
|
||||
ssize_t nread = 0;
|
||||
if (data.has_value()) {
|
||||
nread = min(static_cast<off_t>(data.value().size() - offset), static_cast<off_t>(count));
|
||||
memcpy(buffer, data.value().data() + offset, nread);
|
||||
if (nread == 0 && description && description->generator_cache())
|
||||
description->generator_cache().clear();
|
||||
}
|
||||
|
||||
return nread;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user