mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
dump: always allocate >=8 bytes for multibit
The multibit runtime assumes that it is always safe to read 8 bytes, so we must over-allocate for smaller sizes. Caught by ASan.
This commit is contained in:
parent
85f7790a21
commit
bdae3d5b80
@ -681,10 +681,17 @@ vector<u32> sparseIterValues(const mmbit_sparse_iter *it, u32 num_bits) {
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<u8> bits(mmbit_size(num_bits), u8{0xff}); // All bits on.
|
// Populate a multibit structure with all-ones. Note that the multibit
|
||||||
vector<mmbit_sparse_state> state(MAX_SPARSE_ITER_STATES);
|
// runtime assumes that it is always safe to read 8 bytes, so we must
|
||||||
|
// over-allocate for smaller sizes.
|
||||||
|
const size_t num_bytes = mmbit_size(num_bits);
|
||||||
|
vector<u8> bits(max(size_t{8}, num_bytes), u8{0xff}); // All bits on.
|
||||||
const u8 *b = bits.data();
|
const u8 *b = bits.data();
|
||||||
|
if (num_bytes < 8) {
|
||||||
|
b += 8 - num_bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<mmbit_sparse_state> state(MAX_SPARSE_ITER_STATES);
|
||||||
mmbit_sparse_state *s = state.data();
|
mmbit_sparse_state *s = state.data();
|
||||||
|
|
||||||
u32 idx = 0;
|
u32 idx = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user