Merge pull request 'Fix null pointers passed to memcmp/memcpy in skip_list' (#65) from weaselbot/conflict-set:weaselbot/issue-64 into main
CI / pre-commit (push) Successful in 2m13s
CI / release (arm64, ubuntu-latest-arm64) (push) Successful in 3m36s
CI / test (-DCMAKE_BUILD_TYPE=Debug, debug) (push) Successful in 3m38s
CI / test (-DCMAKE_CXX_FLAGS=-DUSE_64_BIT=1, 64-bit-versions) (push) Successful in 3m34s
CI / test (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc) (push) Successful in 3m40s
CI / test (-DUSE_SIMD_FALLBACK=ON, simd-fallback) (push) Successful in 3m30s
CI / release (amd64, ubuntu-latest-amd64) (push) Successful in 5m7s
CI / coverage (push) Successful in 3m45s

Reviewed-on: #65
This commit was merged in pull request #65.
This commit is contained in:
2026-07-13 21:55:52 +00:00
+8 -3
View File
@@ -38,6 +38,9 @@ std::span<const uint8_t> keyAfter(Arena &arena, std::span<const uint8_t> key) {
std::span<const uint8_t> copyToArena(Arena &arena,
std::span<const uint8_t> key) {
if (key.size() == 0) {
return std::span<const uint8_t>();
}
auto result = std::span<uint8_t>(new (arena) uint8_t[key.size()], key.size());
memcpy(result.data(), key.data(), key.size());
return result;
@@ -97,7 +100,7 @@ force_inline bool getCharacter(const KeyInfo &ki, int character,
bool operator<(const KeyInfo &lhs, const KeyInfo &rhs) {
int i = std::min(lhs.key.size(), rhs.key.size());
int c = memcmp(lhs.key.data(), rhs.key.data(), i);
int c = i > 0 ? memcmp(lhs.key.data(), rhs.key.data(), i) : 0;
if (c != 0)
return c < 0;
@@ -287,7 +290,8 @@ private:
static force_inline bool less(const uint8_t *a, int aLen, const uint8_t *b,
int bLen) {
int c = memcmp(a, b, std::min(aLen, bLen));
int n = std::min(aLen, bLen);
int c = n > 0 ? memcmp(a, b, n) : 0;
if (c < 0)
return true;
if (c > 0)
@@ -754,7 +758,8 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
void addWrites(const ConflictSet::WriteRange *writes, int count,
int64_t writeVersion) {
auto points = std::vector<KeyInfo>(count * 2);
auto points = std::vector<KeyInfo>();
points.reserve(count * 2);
Arena arena;
for (int r = 0; r < count; r++) {