Skip to content

Commit 3c2c129

Browse files
authored
Account for current pointer being outside of the buffer
Differential Revision: D65118896 Pull Request resolved: #316
1 parent 8ac81b7 commit 3c2c129

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/torchcodec/decoders/_core/FFMPEGCommon.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ AVIOContext* AVIOBytesContext::getAVIO() {
6969
int AVIOBytesContext::read(void* opaque, uint8_t* buf, int buf_size) {
7070
struct AVIOBufferData* bufferData =
7171
static_cast<struct AVIOBufferData*>(opaque);
72+
TORCH_CHECK(
73+
bufferData->current <= bufferData->size,
74+
"Tried to read outside of the buffer: current=",
75+
bufferData->current,
76+
", size=",
77+
bufferData->size);
7278
buf_size = FFMIN(buf_size, bufferData->size - bufferData->current);
7379
TORCH_CHECK(
7480
buf_size >= 0,

0 commit comments

Comments
 (0)