Skip to content

Commit 2cfc360

Browse files
fmassaTilak Sharma
and
Tilak Sharma
authored
Fix overflow error for large buffers. (#2303)
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 <[email protected]>
1 parent 3e06bc6 commit 2cfc360

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchvision/csrc/cpu/video_reader/VideoReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ torch::List<torch::Tensor> readVideo(
311311
videoFrame = torch::zeros(
312312
{numVideoFrames, outHeight, outWidth, numChannels}, torch::kByte);
313313
expectedWrittenBytes =
314-
numVideoFrames * outHeight * outWidth * numChannels;
314+
(size_t)numVideoFrames * outHeight * outWidth * numChannels;
315315
}
316316

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

0 commit comments

Comments
 (0)