forked from OSchip/llvm-project
Fix stack-use-after free after r359580
`Candidate` was a StringRef refering to a temporary string. Instead, create a local variable for the string and use a StringRef referring to that. llvm-svn: 359604
This commit is contained in:
parent
b4989294c8
commit
e7fa09e4ae
|
@ -296,9 +296,10 @@ unsigned OptTable::findNearest(StringRef Option, std::string &NearestString,
|
|||
// "--help" over "-help".
|
||||
for (int P = 0; const char *const CandidatePrefix = CandidateInfo.Prefixes[P]; P++) {
|
||||
std::string NormalizedName = (LHS + Delimiter).str();
|
||||
StringRef Candidate = (CandidatePrefix + CandidateName).str();
|
||||
std::string Candidate = (CandidatePrefix + CandidateName).str();
|
||||
StringRef CandidateRef = Candidate;
|
||||
unsigned Distance =
|
||||
Candidate.edit_distance(NormalizedName, /*AllowReplacements=*/true,
|
||||
CandidateRef.edit_distance(NormalizedName, /*AllowReplacements=*/true,
|
||||
/*MaxEditDistance=*/BestDistance);
|
||||
if (Distance < BestDistance) {
|
||||
BestDistance = Distance;
|
||||
|
|
Loading…
Reference in New Issue