dynamicbloom fix: don't offset address when it is already aligned

Summary: this causes overflow and asan failure

Test Plan: make asan_check

Reviewers: igor

Reviewed By: igor

CC: leveldb

Differential Revision: https://reviews.facebook.net/D17301
This commit is contained in:
Lei Jin 2014-03-28 17:30:20 -07:00
parent 43a593a6d9
commit 550cca7192

View file

@ -39,7 +39,7 @@ DynamicBloom::DynamicBloom(uint32_t total_bits,
sz += CACHE_LINE_SIZE - 1;
}
raw_ = new unsigned char[sz]();
if (kBlocked) {
if (kBlocked && (reinterpret_cast<uint64_t>(raw_) % CACHE_LINE_SIZE)) {
data_ = raw_ + CACHE_LINE_SIZE -
reinterpret_cast<uint64_t>(raw_) % CACHE_LINE_SIZE;
} else {