Skip to content

Commit ffc3189

Browse files
authored
[7.x][ML] Fixed errors identified by valgrind memcheck (#1450)
Valgrind memcheck was run over the unit test suite. The tool picked up an error related to unit test code only and another in production code itself. Backports #1445
1 parent 6e17018 commit ffc3189

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/core/CPackedBitVector.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ bool CPackedBitVector::fromDelimited(const std::string& str) {
143143
CPersistUtils::fromString(str.substr(pos + 1), runLengthBytes)) {
144144
m_First = (first != 0);
145145
m_Parity = (parity != 0);
146+
runLengthBytes.push_back(0);
146147
for (std::size_t j = 0, runLength = read(runLengthBytes[j]);
147-
j < runLengthBytes.size(); runLength += read(runLengthBytes[++j])) {
148+
j + 1 < runLengthBytes.size(); runLength += read(runLengthBytes[++j])) {
148149
if (complete(runLengthBytes[j])) {
149150
appendRun(runLength, m_LastRunBytes, m_RunLengthBytes);
150151
runLength = 0;

lib/core/unittest/CPackedBitVectorTest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ BOOST_AUTO_TEST_CASE(testInternals) {
234234

235235
auto byteItr = runLengthBytes.cbegin();
236236
for (std::size_t j = 0; j < allRunLengths.size(); ++j) {
237-
BOOST_TEST_REQUIRE(allRunLengths[j],
238-
CPackedBitVectorInternals::popRunLength(byteItr));
237+
std::size_t readLength{CPackedBitVectorInternals::popRunLength(byteItr)};
238+
BOOST_REQUIRE_EQUAL(allRunLengths[j], readLength);
239239
}
240240
}
241241
}

0 commit comments

Comments
 (0)