mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 04:50:29 +00:00
LibCore: Use Vector instead of VLA in ArgsParser::parse()
If there happens to be zero positional arguments, this constructs a 0-length VLA, which is UB caught by UBSAN.
This commit is contained in:
parent
11214bc94d
commit
b9d65da5c8
Notes:
sideshowbarker
2024-07-19 01:59:31 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/b9d65da5c89 Pull-request: https://github.com/SerenityOS/serenity/pull/7157 Issue: https://github.com/SerenityOS/serenity/issues/7073 Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/metmo
1 changed files with 2 additions and 1 deletions
|
@ -106,7 +106,8 @@ bool ArgsParser::parse(int argc, char** argv, bool exit_on_failure)
|
|||
// We're done processing options, now let's parse positional arguments.
|
||||
|
||||
int values_left = argc - optind;
|
||||
int num_values_for_arg[m_positional_args.size()];
|
||||
Vector<int, 16> num_values_for_arg;
|
||||
num_values_for_arg.resize(m_positional_args.size(), true);
|
||||
int total_values_required = 0;
|
||||
for (size_t i = 0; i < m_positional_args.size(); i++) {
|
||||
auto& arg = m_positional_args[i];
|
||||
|
|
Loading…
Reference in a new issue