Skip to content

Commit

Permalink
Merge 75e9950 into 01950eb
Browse files Browse the repository at this point in the history
  • Loading branch information
ylavic committed Apr 28, 2019
2 parents 01950eb + 75e9950 commit 9ccdfd6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions example/sortkeys/sortkeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ int main() {
// C++11 supports std::move() of Value so it always have no problem for std::sort().
// Some C++03 implementations of std::sort() requires copy constructor which causes compilation error.
// Needs a sorting function only depends on std::swap() instead.
#if __cplusplus >= 201103L || !defined(__GLIBCXX__)
#if __cplusplus >= 201103L || (!defined(__GLIBCXX__) && (!defined(_MSC_VER) || _MSC_VER >= 1900))
std::sort(d.MemberBegin(), d.MemberEnd(), NameComparator());
#endif

printIt(d);

Expand All @@ -59,4 +58,5 @@ int main() {
"zeta": false
}
*/
#endif
}
6 changes: 4 additions & 2 deletions include/rapidjson/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,10 @@ class GenericValue {
*/
GenericValue& operator=(GenericValue& rhs) RAPIDJSON_NOEXCEPT {
if (RAPIDJSON_LIKELY(this != &rhs)) {
this->~GenericValue();
RawAssign(rhs);
GenericValue temp;
temp.RawAssign(rhs); // Save and clear rhs, required if it's a sub-Value of
this->~GenericValue(); // this-Value being destroyed, otherwise rhs may be
RawAssign(temp); // used after free here.
}
return *this;
}
Expand Down

0 comments on commit 9ccdfd6

Please sign in to comment.