1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14: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:
sin-ack 2022-07-11 19:53:29 +00:00 committed by Andreas Kling
parent e3da0adfe6
commit c70f45ff44
75 changed files with 264 additions and 203 deletions

View file

@ -295,7 +295,7 @@ Result<void, int> apply_modes(size_t parameter_count, char** raw_parameters, ter
Vector<StringView> parameters;
parameters.ensure_capacity(parameter_count);
for (size_t i = 0; i < parameter_count; ++i)
parameters.append(StringView(raw_parameters[i]));
parameters.append(StringView { raw_parameters[i], strlen(raw_parameters[i]) });
auto parse_baud = [&](size_t idx) -> Optional<speed_t> {
auto maybe_numeric_value = parameters[idx].to_uint<uint32_t>();