From 50cb424c348fe82814196e9ccc04e7efb69d82ca Mon Sep 17 00:00:00 2001 From: ylavic Date: Mon, 15 Mar 2021 23:56:55 +0100 Subject: [PATCH] Test assignment from inner Value. --- test/unittest/valuetest.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/valuetest.cpp b/test/unittest/valuetest.cpp index 00f0652..f34d4b0 100644 --- a/test/unittest/valuetest.cpp +++ b/test/unittest/valuetest.cpp @@ -1119,6 +1119,16 @@ TEST(Value, Array) { z.SetArray(); EXPECT_TRUE(z.IsArray()); EXPECT_TRUE(z.Empty()); + + // PR #1503: assign from inner Value + { + CrtAllocator a; // Free() is not a noop + GenericValue, CrtAllocator> nullValue; + GenericValue, CrtAllocator> arrayValue(kArrayType); + arrayValue.PushBack(nullValue, a); + arrayValue = arrayValue[0]; // shouldn't crash (use after free) + EXPECT_TRUE(arrayValue.IsNull()); + } } TEST(Value, ArrayHelper) {