mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-16 14:32:18 +00:00
LibRegex: Don't do out-of-bound match accesses when a test fails
This commit is contained in:
parent
a245ea1743
commit
e5af15a6e9
Notes:
sideshowbarker
2024-07-18 08:47:31 +09:00
Author: https://github.com/alimpfard
Commit: e5af15a6e9
Pull-request: https://github.com/SerenityOS/serenity/pull/8847
Reviewed-by: https://github.com/MaxWipfli
Reviewed-by: https://github.com/linusg ✅
Reviewed-by: https://github.com/trflynn89
1 changed files with 9 additions and 5 deletions
|
@ -458,10 +458,12 @@ TEST_CASE(a_star)
|
|||
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
EXPECT_EQ(re.search(haystack.view(), result, PosixFlags::Multiline), true);
|
||||
EXPECT_EQ(result.count, 32u);
|
||||
EXPECT_EQ(result.matches.at(0).view.length(), 0u);
|
||||
EXPECT_EQ(result.matches.at(10).view.length(), 1u);
|
||||
EXPECT_EQ(result.matches.at(10).view, "a");
|
||||
EXPECT_EQ(result.matches.at(31).view.length(), 0u);
|
||||
if (result.count == 32u) {
|
||||
EXPECT_EQ(result.matches.at(0).view.length(), 0u);
|
||||
EXPECT_EQ(result.matches.at(10).view.length(), 1u);
|
||||
EXPECT_EQ(result.matches.at(10).view, "a");
|
||||
EXPECT_EQ(result.matches.at(31).view.length(), 0u);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(simple_period_end_benchmark)
|
||||
|
@ -624,5 +626,7 @@ TEST_CASE(case_insensitive_match)
|
|||
auto result = re.match("AEKFCD");
|
||||
|
||||
EXPECT_EQ(result.success, true);
|
||||
EXPECT_EQ(result.matches.at(0).column, 4ul);
|
||||
if (result.success) {
|
||||
EXPECT_EQ(result.matches.at(0).column, 4ul);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue