Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cpp/src/phonenumbers/phonenumbermatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,11 @@ bool PhoneNumberMatcher::AllNumberGroupsAreExactlyPresent(
candidate_groups.push_back(digit_block);
}

// Guard against size_t underflow when candidate_groups is empty.
if (candidate_groups.empty()) {
return false;
}

// Set this to the last group, skipping it if the number has an extension.
int candidate_number_group_index = static_cast<int>(
phone_number.has_extension() ? candidate_groups.size() - 2
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/phonenumbers/phonenumberutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,9 @@ class PhoneNumberRegExpsAndMappings {
StrCat("(", kDigits, "|", kRfc3966VisualSeparator, ")")),
alphanum_(StrCat(kValidAlphaInclUppercase, kDigits)),
rfc3966_domainlabel_(
StrCat("[", alphanum_, "]+((\\-)*[", alphanum_, "])*")),
StrCat("[", alphanum_, "]+(-+[", alphanum_, "]+)*")),
rfc3966_toplabel_(StrCat("[", kValidAlphaInclUppercase,
"]+((\\-)*[", alphanum_, "])*")),
"]+(-+[", alphanum_, "]+)*")),
regexp_factory_(new RegExpFactory()),
regexp_cache_(new RegExpCache(*regexp_factory_.get(), 128)),
diallable_char_mappings_(),
Expand Down