From 7025d19f95a224bc44e2ede203bc9f6e90273ec8 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Wed, 3 May 2023 00:03:08 +0530 Subject: [PATCH 1/2] fix 64bit shift bug --- cpp/src/io/avro/avro.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/src/io/avro/avro.cpp b/cpp/src/io/avro/avro.cpp index 6312fbf93a9..2eff0bc8a75 100644 --- a/cpp/src/io/avro/avro.cpp +++ b/cpp/src/io/avro/avro.cpp @@ -27,8 +27,8 @@ template <> uint64_t container::get_encoded() { uint64_t val = 0; - for (uint64_t len = 0; len < 64; len += 7) { - auto const byte = get_raw(); + for (uint8_t len = 0; len < 64; len += 7) { + uint64_t const byte = get_raw(); val |= (byte & 0x7f) << len; if (byte < 0x80) break; } From 8e8a209511b195aa6e666da6bc112120168d5ee5 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Fri, 12 May 2023 20:59:09 +0530 Subject: [PATCH 2/2] address review comments --- cpp/src/io/avro/avro.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/src/io/avro/avro.cpp b/cpp/src/io/avro/avro.cpp index 2eff0bc8a75..3c8524588af 100644 --- a/cpp/src/io/avro/avro.cpp +++ b/cpp/src/io/avro/avro.cpp @@ -27,7 +27,8 @@ template <> uint64_t container::get_encoded() { uint64_t val = 0; - for (uint8_t len = 0; len < 64; len += 7) { + for (auto len = 0; len < 64; len += 7) { + // 64-bit int since shift left is upto 64. uint64_t const byte = get_raw(); val |= (byte & 0x7f) << len; if (byte < 0x80) break;