diff --git a/SOURCES/0002-vector-fix-referencing-empty-array-rhel90.patch b/SOURCES/0002-vector-fix-referencing-empty-array-rhel90.patch new file mode 100644 index 0000000..103aee0 --- /dev/null +++ b/SOURCES/0002-vector-fix-referencing-empty-array-rhel90.patch @@ -0,0 +1,73 @@ +diff --git a/include/libpmemobj++/container/vector.hpp b/include/libpmemobj++/container/vector.hpp +--- a/include/libpmemobj++/container/vector.hpp ++++ b/include/libpmemobj++/container/vector.hpp +@@ -668,7 +668,7 @@ vector::assign(size_type count, const_reference value) + add_data_to_tx(0, size_old); + + std::fill_n( +- &_data[0], ++ _data.get(), + (std::min)(count, + static_cast(size_old)), + value); +@@ -1600,7 +1600,7 @@ vector::insert(const_iterator pos, size_type count, const value_type &value) + single_element_iterator(&value, count)); + }); + +- return iterator(&_data[static_cast(idx)]); ++ return iterator(_data.get() + static_cast(idx)); + } + + /** +@@ -1843,7 +1843,7 @@ typename vector::iterator + vector::erase(const_iterator first, const_iterator last) + { + size_type idx = static_cast( +- std::distance(const_iterator(&_data[0]), first)); ++ std::distance(const_iterator(_data.get()), first)); + size_type count = static_cast(std::distance(first, last)); + + if (count == 0) +@@ -2306,10 +2306,11 @@ vector::internal_insert(size_type idx, InputIt first, InputIt last) + auto count = static_cast(std::distance(first, last)); + + if (_capacity >= size() + count) { +- pointer dest = +- &_data[static_cast(size() + count)]; +- pointer begin = &_data[static_cast(idx)]; +- pointer end = &_data[static_cast(size())]; ++ pointer dest = _data.get() + ++ static_cast(size() + count); ++ pointer begin = _data.get() + static_cast(idx); ++ pointer end = ++ _data.get() + static_cast(size()); + + add_data_to_tx(idx, size() - idx + count); + +@@ -2327,9 +2328,11 @@ vector::internal_insert(size_type idx, InputIt first, InputIt last) + + auto old_data = _data; + auto old_size = _size; +- pointer old_begin = &_data[0]; +- pointer old_mid = &_data[static_cast(idx)]; +- pointer old_end = &_data[static_cast(size())]; ++ pointer old_begin = _data.get(); ++ pointer old_mid = ++ _data.get() + static_cast(idx); ++ pointer old_end = ++ _data.get() + static_cast(size()); + + _data = nullptr; + _size = _capacity = 0; +@@ -2397,7 +2400,7 @@ vector::realloc(size_type capacity_new) + + auto old_data = _data; + auto old_size = _size; +- pointer old_begin = &_data[0]; ++ pointer old_begin = _data.get(); + pointer old_end = capacity_new < _size + ? &_data[static_cast(capacity_new)] + : &_data[static_cast(size())]; +-- +2.27.0 + diff --git a/SPECS/libpmemobj-cpp.spec b/SPECS/libpmemobj-cpp.spec index ef23412..ae871c7 100644 --- a/SPECS/libpmemobj-cpp.spec +++ b/SPECS/libpmemobj-cpp.spec @@ -4,7 +4,7 @@ Name: libpmemobj-cpp Version: 1.12 -Release: 7%{?dist} +Release: 8%{?dist} Summary: C++ bindings for libpmemobj # Note: tests/external/libcxx is dual licensed using University of Illinois "BSD-Like" license and the MIT license. It's used only during development/testing and is NOT part of the binary RPM. License: BSD @@ -13,6 +13,7 @@ URL: http://pmem.io/pmdk/cpp_obj/ Source0: https://github.com/pmem/%{name}/archive/%{upstreamversion}.tar.gz#/%{name}-%{upstreamversion}.tar.gz Patch0: 0001-vector-Fix-undefined-behaviour-on-realloc.patch +Patch1: 0002-vector-fix-referencing-empty-array-rhel90.patch BuildRequires: libpmemobj-devel >= %{min_libpmemobj_ver} BuildRequires: cmake >= 3.3 @@ -99,6 +100,8 @@ HTML documentation for libpmemobj++. %prep %setup -q -n libpmemobj-cpp-%{upstreamversion} +%patch0 -p1 +%patch1 -p1 %build mkdir build @@ -112,6 +115,11 @@ cd build %make_install %changelog +* Mon Feb 28 2022 Bryan Gurney - 1.12-8 +- Apply patch to fix undefined behavior on realloc +- Also add and apply patch to fix referencing empty array +- Related: rhbz#2034641 + * Mon Jan 24 2022 Bryan Gurney - 1.12-7 - Add patch to fix undefined behavior on realloc - Related: rhbz#2034641