rapidjson
rapidjson copied to clipboard
Out-of-range access in unit test
Issue was initially found in CentOS 7 docker with gcc-11 (devtoolset-11).
[68/82] Building CXX object test/unittest/CMakeFiles/unittest.dir/uritest.cpp.o
[69/82] Building CXX object test/unittest/CMakeFiles/unittest.dir/writertest.cpp.o
[70/82] Building CXX object test/unittest/CMakeFiles/unittest.dir/pointertest.cpp.o
FAILED: test/unittest/CMakeFiles/unittest.dir/pointertest.cpp.o
ccache /opt/rh/devtoolset-11/root/usr/bin/g++ -DRAPIDJSON_HAS_STDSTRING -I/tmp/scratch/rapidjson/include -isystem /tmp/scratch/rapidjson/thirdparty/gtest/googletest/include -fdebug-prefix-map='/tmp/scratch'='/usr/local/src' -g -march=native -Wa
ll -Wextra -Werror -DRAPIDJSON_HAS_STDSTRING=1 -O3 -DNDEBUG -Weffc++ -Wswitch-default -Wfloat-equal -Wconversion -Wsign-conversion -std=gnu++11 -MD -MT test/unittest/CMakeFiles/unittest.dir/pointertest.cpp.o -MF test/unittest/CMakeFiles/unittest.dir/poin
tertest.cpp.o.d -o test/unittest/CMakeFiles/unittest.dir/pointertest.cpp.o -c /tmp/scratch/rapidjson/test/unittest/pointertest.cpp
In file included from ../test/unittest/pointertest.cpp:16:
In member function ‘rapidjson::GenericPointer<ValueType, Allocator>::Ch* rapidjson::GenericPointer<ValueType, Allocator>::CopyFromRaw(const rapidjson::GenericPointer<ValueType, Allocator>&, std::size_t, std::size_t) [with ValueType = rapidjson:
:GenericValue<rapidjson::UTF8<> >; Allocator = rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>]’,
inlined from ‘rapidjson::GenericPointer<ValueType, Allocator>& rapidjson::GenericPointer<ValueType, Allocator>::operator=(const rapidjson::GenericPointer<ValueType, Allocator>&) [with ValueType = rapidjson::GenericValue<rapidjson::UTF8<> >;
Allocator = rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>]’ at ../include/rapidjson/pointer.h:197:28,
inlined from ‘virtual void Pointer_Issue1899_Test::TestBody()’ at ../test/unittest/pointertest.cpp:1726:22:
../include/rapidjson/pointer.h:902:24: error: ‘void* memcpy(void*, const void*, size_t)’ offset [0, 5] is out of the bounds [0, 0] [-Werror=array-bounds]
902 | std::memcpy(nameBuffer_, rhs.nameBuffer_, nameBufferSize * sizeof(Ch));
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
[71/82] Building CXX object test/unittest/CMakeFiles/unittest.dir/documenttest.cpp.o
[72/82] Building CXX object test/unittest/CMakeFiles/unittest.dir/valuetest.cpp.o