Merge pull request #1413 from ylavic/schema_regex_leak
Fix a memory leak for invalid std::regex in Schema.
This commit is contained in:
commit
30d92a6399
@ -1150,10 +1150,12 @@ private:
|
|||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
RegexType* CreatePattern(const ValueType& value) {
|
RegexType* CreatePattern(const ValueType& value) {
|
||||||
if (value.IsString())
|
if (value.IsString())
|
||||||
|
RegexType *r = static_cast<RegexType*>(allocator_->Malloc(sizeof(RegexType)));
|
||||||
try {
|
try {
|
||||||
return new (allocator_->Malloc(sizeof(RegexType))) RegexType(value.GetString(), std::size_t(value.GetStringLength()), std::regex_constants::ECMAScript);
|
return new (r) RegexType(value.GetString(), std::size_t(value.GetStringLength()), std::regex_constants::ECMAScript);
|
||||||
}
|
}
|
||||||
catch (const std::regex_error&) {
|
catch (const std::regex_error&) {
|
||||||
|
AllocatorType::Free(r);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user