diff --git a/example/parsebyparts/parsebyparts.cpp b/example/parsebyparts/parsebyparts.cpp index 57eed005d..a377efd4e 100644 --- a/example/parsebyparts/parsebyparts.cpp +++ b/example/parsebyparts/parsebyparts.cpp @@ -21,12 +21,15 @@ class AsyncDocumentParser { AsyncDocumentParser(Document& d) : stream_(*this) , d_(d) - , parseThread_(&AsyncDocumentParser::Parse, this) + , parseThread_() , mutex_() , notEmpty_() , finish_() , completed_() - {} + { + // Create and execute thread after all member variables are initialized. + parseThread_ = std::thread(&AsyncDocumentParser::Parse, this); + } ~AsyncDocumentParser() { if (!parseThread_.joinable()) diff --git a/include/rapidjson/internal/strfunc.h b/include/rapidjson/internal/strfunc.h index 2edfae526..de41d8f9c 100644 --- a/include/rapidjson/internal/strfunc.h +++ b/include/rapidjson/internal/strfunc.h @@ -28,6 +28,7 @@ namespace internal { */ template inline SizeType StrLen(const Ch* s) { + RAPIDJSON_ASSERT(s != 0); const Ch* p = s; while (*p) ++p; return SizeType(p - s); @@ -36,6 +37,8 @@ inline SizeType StrLen(const Ch* s) { //! Returns number of code points in a encoded string. template bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) { + RAPIDJSON_ASSERT(s != 0); + RAPIDJSON_ASSERT(outCount != 0); GenericStringStream is(s); const typename Encoding::Ch* end = s + length; SizeType count = 0; diff --git a/include/rapidjson/prettywriter.h b/include/rapidjson/prettywriter.h index 0dcb0fee9..c6f0216e9 100644 --- a/include/rapidjson/prettywriter.h +++ b/include/rapidjson/prettywriter.h @@ -91,12 +91,14 @@ class PrettyWriter : public Writer