From 009a3ad24ce45014f0c738f4a7c5a12fbfd41995 Mon Sep 17 00:00:00 2001 From: Stefano Fiorentino Date: Sun, 18 Nov 2018 23:01:24 +0100 Subject: [PATCH] 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 --- src/test_lib_json/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index 32f424b..23da4b3 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -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) {