mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-01 15:14:26 +08:00
string: Fix crash with _GLIBCXX_ASSERTIONS
This asserted because we accessed wcstring::front() when it was empty. Instead, check explicitly for it being empty before. Fixes #5479
This commit is contained in:
parent
028bff7b44
commit
059804612a
|
@ -622,9 +622,13 @@ class wildcard_matcher_t : public string_matcher_t {
|
|||
}
|
||||
}
|
||||
if (opts.entire) {
|
||||
// If the pattern is empty, this becomes one ANY_STRING that matches everything.
|
||||
if (wcpattern.front() != ANY_STRING) wcpattern.insert(0, 1, ANY_STRING);
|
||||
if (wcpattern.back() != ANY_STRING) wcpattern.push_back(ANY_STRING);
|
||||
if (!wcpattern.empty()) {
|
||||
if (wcpattern.front() != ANY_STRING) wcpattern.insert(0, 1, ANY_STRING);
|
||||
if (wcpattern.back() != ANY_STRING) wcpattern.push_back(ANY_STRING);
|
||||
} else {
|
||||
// If the pattern is empty, this becomes one ANY_STRING that matches everything.
|
||||
wcpattern.push_back(ANY_STRING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user