adamreeve commented on code in PR #47998:
URL: https://github.com/apache/arrow/pull/47998#discussion_r2476291891


##########
cpp/src/arrow/util/bit_stream_utils_internal.h:
##########
@@ -198,7 +198,9 @@ inline bool BitWriter::PutValue(uint64_t v, int num_bits) {
     ARROW_DCHECK_EQ(v >> num_bits, 0) << "v = " << v << ", num_bits = " << 
num_bits;
   }
 
-  if (ARROW_PREDICT_FALSE(byte_offset_ * 8 + bit_offset_ + num_bits > 
max_bytes_ * 8))
+  if (ARROW_PREDICT_FALSE(static_cast<int64_t>(byte_offset_) * 8 + bit_offset_ 
+
+                              num_bits >
+                          static_cast<int64_t>(max_bytes_) * 8))

Review Comment:
   This is the main bug fix. Previously `max_bytes_ * 8` could overflow `int`, 
resulting in a negative value on the RHS so that this comparison always 
returned true and the function returned without writing anything to the buffer.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to