Don't pass null to memcpy

This commit is contained in:
2024-05-04 18:17:02 -07:00
parent b7f3b136cc
commit 08583f2ac0

View File

@@ -109,9 +109,13 @@ struct Entry {
e->refCount = 1;
e->priority = XXH3_64bits(key, keyLen);
e->clearTo = clearTo;
memcpy((uint8_t *)e->getKey(), key, keyLen);
if (keyLen > 0) {
memcpy((uint8_t *)e->getKey(), key, keyLen);
}
((uint8_t *)e->getKey())[keyLen] = 0;
memcpy((uint8_t *)e->getVal(), val, std::max(valLen, 0));
if (valLen > 0) {
memcpy((uint8_t *)e->getVal(), val, valLen);
}
return e;
}
};