mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:44:58 +00:00
Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the StringView users. This is an important step towards the goal of removing StringView(char const*), as it moves the responsibility of calculating the size of the string to the user of the StringView (which will prevent naive uses causing OOB access).
This commit is contained in:
parent
e3da0adfe6
commit
c70f45ff44
75 changed files with 264 additions and 203 deletions
|
@ -294,7 +294,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
.short_name = 'l',
|
||||
.value_name = "file",
|
||||
.accept_value = [&](char const* str) {
|
||||
if (auto v = StringView { str }; !v.is_empty()) {
|
||||
if (auto v = StringView { str, strlen(str) }; !v.is_empty()) {
|
||||
modules_to_link_in.append(v);
|
||||
return true;
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
.short_name = 0,
|
||||
.value_name = "u64",
|
||||
.accept_value = [&](char const* str) -> bool {
|
||||
if (auto v = StringView { str }.to_uint<u64>(); v.has_value()) {
|
||||
if (auto v = StringView { str, strlen(str) }.to_uint<u64>(); v.has_value()) {
|
||||
values_to_push.append(v.value());
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue