fix(PIBitArray): guard pop_back() against empty array

pop_back() called resize(size_ - 1) without checking for empty.
On empty array, uint underflow produced UINT_MAX, causing
bytesInBits(UINT_MAX) overflow and subsequent OOB access.
pop_front() already had this guard; pop_back() was missing it.
This commit is contained in:
2026-08-06 17:01:30 +03:00
committed by andrey
parent c3cd9496dd
commit 3e72f4e533
+4 -1
View File
@@ -173,7 +173,10 @@ public:
//! \~english Remove one bit from the end of array. //! \~english Remove one bit from the end of array.
//! \~russian Удаляет один бит с конца массива. //! \~russian Удаляет один бит с конца массива.
PIBitArray & pop_back() { return resize(size_ - 1); } PIBitArray & pop_back() {
if (size_ == 0) return *this;
return resize(size_ - 1);
}
//! \~english Remove one bit from the beginning of array. //! \~english Remove one bit from the beginning of array.
//! \~russian Удаляет один бит с начала массива. //! \~russian Удаляет один бит с начала массива.