Skip to content

Commit ebdcf7c

Browse files
author
Snow Pettersen
authored
matcher: fix UB bug caused by dereferencing a bad optional (#14271)
Signed-off-by: Snow Pettersen <[email protected]>
1 parent d382fa6 commit ebdcf7c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

source/common/matcher/field_matcher.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ struct FieldMatchResult {
1616
// The result, if matching was completed.
1717
absl::optional<bool> result_;
1818

19-
bool result() const { return *result_; }
19+
// The unwrapped result. Should only be called if match_state_ == MatchComplete.
20+
bool result() const {
21+
ASSERT(match_state_ == MatchState::MatchComplete);
22+
ASSERT(result_.has_value());
23+
return *result_;
24+
}
2025
};
2126

2227
/**
@@ -87,6 +92,7 @@ template <class DataType> class AnyFieldMatcher : public FieldMatcher<DataType>
8792

8893
if (result.match_state_ == MatchState::UnableToMatch) {
8994
unable_to_match_some_matchers = true;
95+
continue;
9096
}
9197

9298
if (result.result()) {

0 commit comments

Comments
 (0)