Merge pull request #2025 from ArtemSarmini/issue-1971-basic_json-push_back

Fixes #1971 (memory leak in basic_json::push_back)
This commit is contained in:
Niels Lohmann 2020-04-10 13:19:14 +02:00 committed by GitHub
commit ea0a7c7b4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 6 deletions

View file

@ -19734,9 +19734,7 @@ class basic_json
// add element to array (move semantics)
m_value.array->push_back(std::move(val));
// invalidate object: mark it null so we do not call the destructor
// cppcheck-suppress accessMoved
val.m_type = value_t::null;
// if val is moved from, basic_json move constructor marks it null so we do not call the destructor
}
/*!