mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Fix off-by-one error in Regex::isValid
llvm-svn: 187992
This commit is contained in:
parent
20c4077bf5
commit
1021d4d06d
@ -43,7 +43,7 @@ bool Regex::isValid(std::string &Error) {
|
|||||||
|
|
||||||
size_t len = llvm_regerror(error, preg, NULL, 0);
|
size_t len = llvm_regerror(error, preg, NULL, 0);
|
||||||
|
|
||||||
Error.resize(len);
|
Error.resize(len - 1);
|
||||||
llvm_regerror(error, preg, &Error[0], len);
|
llvm_regerror(error, preg, &Error[0], len);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -127,4 +127,12 @@ TEST_F(RegexTest, IsLiteralERE) {
|
|||||||
EXPECT_FALSE(Regex::isLiteralERE("abc{1,2}"));
|
EXPECT_FALSE(Regex::isLiteralERE("abc{1,2}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(RegexTest, IsValid) {
|
||||||
|
std::string Error;
|
||||||
|
EXPECT_FALSE(Regex("(foo").isValid(Error));
|
||||||
|
EXPECT_EQ("parentheses not balanced", Error);
|
||||||
|
EXPECT_FALSE(Regex("a[b-").isValid(Error));
|
||||||
|
EXPECT_EQ("invalid character range", Error);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user