martin-g commented on code in PR #3433:
URL: https://github.com/apache/avro/pull/3433#discussion_r2454856011
##########
lang/c++/impl/FileStream.cc:
##########
@@ -205,8 +205,15 @@ class BufferCopyInInputStream : public SeekableInputStream
{
void seek(int64_t position) final {
// BufferCopyIn::seek is relative to byteCount_, whereas position is
// absolute.
- in_->seek(position - byteCount_ - available_);
- byteCount_ = position;
+ int64_t offset = position - static_cast<int64_t>(byteCount_) -
static_cast<int64_t>(available_);
+ if (offset < 0) {
+ throw Exception("Negative offset in seek");
+ }
+ in_->seek(static_cast<size_t>(offset));
Review Comment:
~Do we care about 32-bit systems ?~
Update: Actually this PR is specifically for improving the things on 32bit
systems.
The cast from `int64_t` to `size_t` may truncate on 32bit
--
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]