Skip to content

Commit

Permalink
Fix overflow error for large buffers. (#2303)
Browse files Browse the repository at this point in the history
Summary:
Allow writes of >= 2^32 bytes. High-res video can cross this threshold sometimes.
LHS is `size_t`, but RHS is all `int32`, and will overflow for output tensors >2Gb.

Reviewed By: jsawruk

Differential Revision: D21255664

fbshipit-source-id: 7b4c5da989777297a89e73615aaeee8c7a13186a

Co-authored-by: Tilak Sharma <tilaksharma@fb.com>
  • Loading branch information
fmassa and Tilak Sharma committed Jun 9, 2020
1 parent 3e06bc6 commit 2cfc360
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torchvision/csrc/cpu/video_reader/VideoReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ torch::List<torch::Tensor> readVideo(
videoFrame = torch::zeros(
{numVideoFrames, outHeight, outWidth, numChannels}, torch::kByte);
expectedWrittenBytes =
numVideoFrames * outHeight * outWidth * numChannels;
(size_t)numVideoFrames * outHeight * outWidth * numChannels;
}

videoFramePts = torch::zeros({numVideoFrames}, torch::kLong);
Expand Down

0 comments on commit 2cfc360

Please sign in to comment.