You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling small::string::substr(pos, count) with a count value larger than the size of the string causes a segfault.
According to the documentation, if count is larger than the size of the string, the function should return the substring from pos to the end of the string.
This is how std::string::substr() behaves.
Steps to Reproduce
#include<small/string.hpp>template<typename T>
std::vector<T>
b_split(const T& str, const std::string_view& delims)
{
std::vector<T> output;
size_t first = 0;
while (first < str.size())
{
constauto second = str.find_first_of(delims, first);
if (first != second)
{
output.emplace_back(str.substr(first, second-first));
}
if (second == std::string::npos)
break;
first = second + 1;
}
return output;
}
intmain()
{
usingnamespacestd::literals;constchar inputStr[] = "This is a ctest";
constauto res = b_split<std::string>(inputStr, ""sv); // OKassert(res.size() == 4);
constauto res2 = b_split<small::string>(inputStr, ""sv); // Crashassert(res.size() == 4);
return0;
}
Output
The app crashes with a segfault when using small::string.
Platform
cross-platform issue - linux
cross-platform issue - windows
cross-platform issue - macos
other: ___________
Environment Details
OS: Windows 10
OS Version: 22H
Compiler: Visual Studio 2022
Compiler version: 17.6.4
Proposed solution
Alternatives I've considered
Additional context
The text was updated successfully, but these errors were encountered:
The problem
Calling
small::string::substr(pos, count)
with acount
value larger than the size of the string causes a segfault.According to the documentation, if
count
is larger than the size of the string, the function should return the substring frompos
to the end of the string.This is how
std::string::substr()
behaves.Steps to Reproduce
Output
The app crashes with a segfault when using
small::string
.Platform
Environment Details
Proposed solution
Alternatives I've considered
Additional context
The text was updated successfully, but these errors were encountered: