Fixed Issue 38: Segmentation fault with CrtAllocator
git-svn-id: https://rapidjson.googlecode.com/svn/trunk@80 c5894555-1306-4e8d-425f-1f6f381ee07c
This commit is contained in:
parent
94d05da2bc
commit
4ee17e67b1
@ -269,8 +269,8 @@ public:
|
|||||||
o.members = (Member*)allocator.Realloc(o.members, oldCapacity * sizeof(Member), o.capacity * sizeof(Member));
|
o.members = (Member*)allocator.Realloc(o.members, oldCapacity * sizeof(Member), o.capacity * sizeof(Member));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o.members[o.size].name = name;
|
o.members[o.size].name.RawAssign(name);
|
||||||
o.members[o.size].value = value;
|
o.members[o.size].value.RawAssign(value);
|
||||||
o.size++;
|
o.size++;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -396,7 +396,7 @@ int z = a[0u].GetInt(); // This works too.
|
|||||||
RAPIDJSON_ASSERT(IsArray());
|
RAPIDJSON_ASSERT(IsArray());
|
||||||
if (data_.a.size >= data_.a.capacity)
|
if (data_.a.size >= data_.a.capacity)
|
||||||
Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : data_.a.capacity * 2, allocator);
|
Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : data_.a.capacity * 2, allocator);
|
||||||
data_.a.elements[data_.a.size++] = value;
|
data_.a.elements[data_.a.size++].RawAssign(value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,3 +591,15 @@ TEST(Value, RemoveLastElement) {
|
|||||||
objVal.RemoveMember("var3"); // Assertion here in r61
|
objVal.RemoveMember("var3"); // Assertion here in r61
|
||||||
EXPECT_FALSE(objVal.HasMember("var3"));
|
EXPECT_FALSE(objVal.HasMember("var3"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue 38: Segmentation fault with CrtAllocator
|
||||||
|
TEST(Document, CrtAllocator) {
|
||||||
|
typedef GenericValue<UTF8<>, CrtAllocator> V;
|
||||||
|
|
||||||
|
V::AllocatorType allocator;
|
||||||
|
V o(kObjectType);
|
||||||
|
o.AddMember("x", 1, allocator); // Should not call destructor on uninitialized name/value of newly allocated members.
|
||||||
|
|
||||||
|
V a(kArrayType);
|
||||||
|
a.PushBack(1, allocator); // Should not call destructor on uninitialized Value of newly allocated elements.
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user