Skip to content

Commit 4643104

Browse files
StilesCrisisStilesCrisis
authored andcommitted
Fix null handler construction
We should not malloc the null-handler object and cast to OutputHandler; we need to actually invoke the constructor via placement new.
1 parent 0ec4e86 commit 4643104

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/rapidjson/schema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ RAPIDJSON_MULTILINEMACRO_END
19281928
const Context& CurrentContext() const { return *schemaStack_.template Top<Context>(); }
19291929

19301930
OutputHandler& CreateNullHandler() {
1931-
return *(nullHandler_ = static_cast<OutputHandler*>(GetStateAllocator().Malloc(sizeof(OutputHandler))));
1931+
return *(nullHandler_ = new (GetStateAllocator().Malloc(sizeof(OutputHandler))) OutputHandler);
19321932
}
19331933

19341934
static const size_t kDefaultSchemaStackCapacity = 1024;

0 commit comments

Comments
 (0)