Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorylavic <ylavic.dev@gmail.com>2018-12-02 01:36:45 +0300
committerylavic <ylavic.dev@gmail.com>2018-12-02 01:36:45 +0300
commit3e6956767ee5da8a9a00453ab32d3e5c322c761a (patch)
treead291c703654a41013682203accfd8fb4e199dcf /include
parenta63216054dfcd37ec94ff48b51d44615f588e425 (diff)
Fix a memory leak for invalid std::regex in Schema.
Diffstat (limited to 'include')
-rw-r--r--include/rapidjson/schema.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h
index fa0d696e..57ec797a 100644
--- a/include/rapidjson/schema.h
+++ b/include/rapidjson/schema.h
@@ -1150,10 +1150,12 @@ private:
template <typename ValueType>
RegexType* CreatePattern(const ValueType& value) {
if (value.IsString())
+ RegexType *r = static_cast<RegexType*>(allocator_->Malloc(sizeof(RegexType)));
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&) {
+ AllocatorType::Free(r);
}
return 0;
}