File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,13 @@ RAPIDJSON_DIAG_OFF(c++98-compat-pedantic)
32
32
#define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 0
33
33
#endif
34
34
35
- #if !RAPIDJSON_SCHEMA_USE_INTERNALREGEX && !defined(RAPIDJSON_SCHEMA_USE_STDREGEX) && (__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
35
+ #if !defined(RAPIDJSON_SCHEMA_USE_STDREGEX)
36
+ #if !RAPIDJSON_SCHEMA_USE_INTERNALREGEX && (__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
36
37
#define RAPIDJSON_SCHEMA_USE_STDREGEX 1
37
38
#else
38
39
#define RAPIDJSON_SCHEMA_USE_STDREGEX 0
39
40
#endif
41
+ #endif
40
42
41
43
#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX
42
44
#include " internal/regex.h"
@@ -1017,12 +1019,17 @@ class Schema {
1017
1019
#elif RAPIDJSON_SCHEMA_USE_STDREGEX
1018
1020
template <typename ValueType>
1019
1021
RegexType* CreatePattern (const ValueType& value) {
1020
- if (value.IsString ())
1022
+ if (value.IsString ()) {
1023
+ RegexType* r = static_cast <RegexType*>(allocator_->Malloc (sizeof (RegexType)));
1021
1024
try {
1022
- return new (allocator_-> Malloc ( sizeof (RegexType)) ) RegexType (value.GetString (), std::size_t (value.GetStringLength ()), std::regex_constants::ECMAScript);
1025
+ new (r ) RegexType (value.GetString (), std::size_t (value.GetStringLength ()), std::regex_constants::ECMAScript);
1023
1026
}
1024
1027
catch (const std::regex_error&) {
1028
+ AllocatorType::Free (r);
1029
+ r = 0 ;
1025
1030
}
1031
+ return r;
1032
+ }
1026
1033
return 0 ;
1027
1034
}
1028
1035
Original file line number Diff line number Diff line change @@ -352,7 +352,7 @@ TEST(SchemaValidator, String_Pattern) {
352
352
353
353
TEST (SchemaValidator, String_Pattern_Invalid) {
354
354
Document sd;
355
- sd.Parse (" {\" type\" :\" string\" ,\" pattern\" :\" a{0 }\" }" ); // TODO: report regex is invalid somehow
355
+ sd.Parse (" {\" type\" :\" string\" ,\" pattern\" :\" a{}\" }" ); // TODO: report regex is invalid somehow
356
356
SchemaDocument s (sd);
357
357
358
358
VALIDATE (s, " \"\" " , true );
You can’t perform that action at this time.
0 commit comments