libstdc++: Fix out-of-bounds string_view access in filesystem::path [PR 97167]
libstdc++-v3/ChangeLog: PR libstdc++/97167 * src/c++17/fs_path.cc (path::_Parser::root_path()): Check for empty string before inspecting the first character. * testsuite/27_io/filesystem/path/append/source.cc: Append empty string_view to path.
This commit is contained in:
parent
809192e77e
commit
49ff88bd0d
|
@ -81,7 +81,7 @@ struct path::_Parser
|
|||
const size_t len = input.size();
|
||||
|
||||
// look for root name or root directory
|
||||
if (is_dir_sep(input[0]))
|
||||
if (len && is_dir_sep(input[0]))
|
||||
{
|
||||
#if SLASHSLASH_IS_ROOTNAME
|
||||
// look for root name, such as "//foo"
|
||||
|
|
|
@ -161,6 +161,15 @@ test06()
|
|||
test(p2, s.c_str());
|
||||
}
|
||||
|
||||
void
|
||||
test07()
|
||||
{
|
||||
path p, p0;
|
||||
std::string_view s;
|
||||
p /= s; // PR libstdc++/97167
|
||||
compare_paths(p, p0);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
|
@ -170,4 +179,5 @@ main()
|
|||
test04();
|
||||
test05();
|
||||
test06();
|
||||
test07();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue