You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reasons, if the memory is not enough for DoAllocMembers(count, allocator), it will got nullptr as return value. However, there seems to be no checks or assert for this sititutation. It took me lots of hours to find the reason, so I want to fix it up and strengthen the robustness for this library. The detailed code is in rapidjson/include/rapidjson/document.h, and it looks like:
//! Initialize this value as object with initial data, without calling destructor.voidSetObjectRaw(Member* members, SizeType count, Allocator& allocator) {
data_.f.flags = kObjectFlag;
if (count) {
Member* m = DoAllocMembers(count, allocator);
SetMembersPointer(m);
printf("the ptr of m is %p\n", m);
std::memcpy(static_cast<void*>(m), members, count * sizeof(Member));
#if RAPIDJSON_USE_MEMBERSMAP
Map* &map = GetMap(m);
MapIterator* mit = GetMapIterators(map);
for (SizeType i = 0; i < count; i++) {
printf("members[%d].name.data_ = %s\n", i, m[i].name.data_.GetString());
new (&mit[i]) MapIterator(map->insert(MapPair(m[i].name.data_, i)));
}
#endif
}
elseSetMembersPointer(0);
data_.o.size = data_.o.capacity = count;
}
I got the ptr of m is 0 when debugging for Migrating the application to MCUs, which have very limited RAMs for malloc. Though the final solution is just to adjust the defination of RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY to 1024.
The text was updated successfully, but these errors were encountered:
For some reasons, if the memory is not enough for
DoAllocMembers(count, allocator)
, it will gotnullptr
as return value. However, there seems to be no checks or assert for this sititutation. It took me lots of hours to find the reason, so I want to fix it up and strengthen the robustness for this library. The detailed code is inrapidjson/include/rapidjson/document.h
, and it looks like:I got the ptr of m is 0 when debugging for Migrating the application to MCUs, which have very limited RAMs for malloc. Though the final solution is just to adjust the defination of
RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY
to 1024.The text was updated successfully, but these errors were encountered: