fix shift UBSAN error in col_buf_encoder.cc
Summary: Add a static cast to perform the left shift as with an unsigned type. make ubsan_check Closes https://github.com/facebook/rocksdb/pull/3517 Reviewed By: sagar0 Differential Revision: D7016044 Pulled By: igorsugak fbshipit-source-id: baf72f6197edd8f7220d010b15a23d6de6a72c49
This commit is contained in:
parent
ab446dc22d
commit
5263da6396
@ -46,13 +46,6 @@ ColBufEncoder *ColBufEncoder::NewColBufEncoder(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ROCKSDB_UBSAN_RUN
|
|
||||||
#if defined(__clang__)
|
|
||||||
__attribute__((__no_sanitize__("shift")))
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
__attribute__((__no_sanitize_undefined__))
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
size_t FixedLengthColBufEncoder::Append(const char *buf) {
|
size_t FixedLengthColBufEncoder::Append(const char *buf) {
|
||||||
if (nullable_) {
|
if (nullable_) {
|
||||||
if (buf == nullptr) {
|
if (buf == nullptr) {
|
||||||
@ -72,7 +65,7 @@ size_t FixedLengthColBufEncoder::Append(const char *buf) {
|
|||||||
col_compression_type_ == kColRleDeltaVarint) {
|
col_compression_type_ == kColRleDeltaVarint) {
|
||||||
int64_t delta = read_val - last_val_;
|
int64_t delta = read_val - last_val_;
|
||||||
// Encode signed delta value
|
// Encode signed delta value
|
||||||
delta = (delta << 1) ^ (delta >> 63);
|
delta = (static_cast<uint64_t>(delta) << 1) ^ (delta >> 63);
|
||||||
write_val = delta;
|
write_val = delta;
|
||||||
last_val_ = read_val;
|
last_val_ = read_val;
|
||||||
} else if (col_compression_type_ == kColDict ||
|
} else if (col_compression_type_ == kColDict ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user