You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2019/08/12 18:55:24 UTC
[impala] 03/03: IMPALA-8846: Undefined behaviour in RleEncoder::Put
This is an automated email from the ASF dual-hosted git repository.
tarmstrong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
commit f26a32f85542bfdbceb7306a06327f66dc30294a
Author: Daniel Becker <da...@cloudera.com>
AuthorDate: Fri Aug 9 10:08:55 2019 +0200
IMPALA-8846: Undefined behaviour in RleEncoder::Put
To test for overflow, we used 'repeat_count_ <=
std::numeric_limits<int32_t>::max()', but this is always true as
repeat_count_ is an int. This could have lead to undefined behaviour
because we increment repeat_count_ afterwards.
Changed the comparison not to allow equality.
Change-Id: I269443d1f1680e672fde7dd88eab5fcb56c65613
Reviewed-on: http://gerrit.cloudera.org:8080/14042
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
be/src/util/rle-encoding.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/be/src/util/rle-encoding.h b/be/src/util/rle-encoding.h
index 4da9fd9..4ea3769 100644
--- a/be/src/util/rle-encoding.h
+++ b/be/src/util/rle-encoding.h
@@ -344,7 +344,7 @@ inline bool RleEncoder::Put(uint64_t value) {
if (UNLIKELY(buffer_full_)) return false;
if (LIKELY(current_value_ == value
- && repeat_count_ <= std::numeric_limits<int32_t>::max())) {
+ && repeat_count_ < std::numeric_limits<int32_t>::max())) {
++repeat_count_;
if (repeat_count_ > 8) {
// This is just a continuation of the current run, no need to buffer the