Skip to content

Commit

Permalink
Account for current pointer being outside of the buffer
Browse files Browse the repository at this point in the history
Differential Revision: D65118896

Pull Request resolved: #316
  • Loading branch information
scotts authored Nov 6, 2024
1 parent 8ac81b7 commit 3c2c129
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/torchcodec/decoders/_core/FFMPEGCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ AVIOContext* AVIOBytesContext::getAVIO() {
int AVIOBytesContext::read(void* opaque, uint8_t* buf, int buf_size) {
struct AVIOBufferData* bufferData =
static_cast<struct AVIOBufferData*>(opaque);
TORCH_CHECK(
bufferData->current <= bufferData->size,
"Tried to read outside of the buffer: current=",
bufferData->current,
", size=",
bufferData->size);
buf_size = FFMIN(buf_size, bufferData->size - bufferData->current);
TORCH_CHECK(
buf_size >= 0,
Expand Down

0 comments on commit 3c2c129

Please sign in to comment.