issue_836: Check if `removed' is a valid pointer before copy data to it

functions involved:
	- bool Value::removeMember(const char* key, const char* cend, Value* removed)

Signed-off-by: Stefano Fiorentino <stefano.fiore84@gmail.com>
This commit is contained in:
Stefano Fiorentino 2018-11-18 23:01:24 +01:00 committed by Hans Johnson
parent 7d16e10113
commit 009a3ad24c

View File

@ -222,6 +222,12 @@ JSONTEST_FIXTURE(ValueTest, objects) {
did = object1_.removeMember("some other id", &got);
JSONTEST_ASSERT_EQUAL(Json::Value("bar"), got);
JSONTEST_ASSERT_EQUAL(false, did);
object1_["some other id"] = "foo";
Json::Value* gotPtr = nullptr;
did = object1_.removeMember("some other id", gotPtr);
JSONTEST_ASSERT_EQUAL(nullptr, gotPtr);
JSONTEST_ASSERT_EQUAL(true, did);
}
JSONTEST_FIXTURE(ValueTest, arrays) {