From 03a013360d0262142e2ee68897098310564bff9e Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Thu, 28 Nov 2024 06:03:44 -0800 Subject: [PATCH] Fix a possible ownership bug Summary: I don't know whether this leads to the crash we've seen, but it seems to be a bug: when we deserialize a set we're adding 8 junk bytes at the end. Reviewed By: malanka Differential Revision: D66573036 fbshipit-source-id: 7c7a22626056204554bfdd49101e11276c52d70a --- glean/rocksdb/ownership.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/glean/rocksdb/ownership.cpp b/glean/rocksdb/ownership.cpp index 07cb02eed..511381f29 100644 --- a/glean/rocksdb/ownership.cpp +++ b/glean/rocksdb/ownership.cpp @@ -139,11 +139,12 @@ std::unique_ptr getSetIterator(DatabaseImpl& db) { auto usetid = key.trustedNat(); // EliasFano needs to be able to read 8 bytes past the end of // the data, so we have to copy the bytes to add padding. + const size_t pad = 8; bytes = hs::ffi::clone_array( reinterpret_cast(iter->value().data()), iter->value().size(), - 8); - binary::Input val(bytes.get(), bytes.size()); + pad); + binary::Input val(bytes.get(), iter->value().size()); exp.op = static_cast(val.trustedNat()); exp.set = deserializeEliasFano(val); return std::pair>(