mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 06:26:15 +02:00
Merge pull request #8825 from trofi/search-path-prefix
src/libexpr/search-path.cc: avoid out-of-bounds read on string_view
This commit is contained in:
commit
7f8c99c70c
1 changed files with 1 additions and 1 deletions
|
@ -10,7 +10,7 @@ std::optional<std::string_view> SearchPath::Prefix::suffixIfPotentialMatch(
|
||||||
|
|
||||||
/* Non-empty prefix and suffix must be separated by a /, or the
|
/* Non-empty prefix and suffix must be separated by a /, or the
|
||||||
prefix is not a valid path prefix. */
|
prefix is not a valid path prefix. */
|
||||||
bool needSeparator = n > 0 && (path.size() - n) > 0;
|
bool needSeparator = n > 0 && n < path.size();
|
||||||
|
|
||||||
if (needSeparator && path[n] != '/') {
|
if (needSeparator && path[n] != '/') {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
Loading…
Reference in a new issue