mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 08:56:10 +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
3a885d5e82
commit
9d4e460b29
@ -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…
x
Reference in New Issue
Block a user