Fix a crasher found by libFuzzer
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245849 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -21,6 +21,28 @@
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
extern "C" void LLVMFuzzerTestOneInput(const char *data)
|
||||
{
|
||||
size_t size = strlen(data);
|
||||
if (size > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::regex::flag_type flag = std::regex_constants::grep;
|
||||
std::string s((const char *)data, size);
|
||||
std::regex re(s, flag);
|
||||
std::regex_match(s, re);
|
||||
}
|
||||
catch (std::regex_error &ex) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fuzz_tests() // patterns that the fuzzer has found
|
||||
{
|
||||
LLVMFuzzerTestOneInput(R"XX(Õ)_%()()((\8'_%()_%()_%()_%(()_%()_%()_%(.t;)()¥f()_%()(.)_%;)()!¥f(((()()XX");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -55,4 +77,5 @@ int main()
|
||||
assert(m.position(0) == 0);
|
||||
assert(m.str(0) == "");
|
||||
}
|
||||
fuzz_tests();
|
||||
}
|
||||
|
Reference in New Issue
Block a user