Skip to content

Commit bacd46d

Browse files
author
SuslikV
authored
Fix crash during seeking at the start of the file
Due to seeking optimizations the file can be closed and reopened. The packet's pointer becomes NULL in this case. This change ensures that packet's pointer is valid after seeking performed (if any).
1 parent 04d1a58 commit bacd46d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/FFmpegReader.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,11 @@ std::shared_ptr<Frame> FFmpegReader::ReadStream(int64_t requested_frame) {
921921
continue;
922922
}
923923

924+
// Packet may become NULL on Close inside Seek if CheckSeek returns false
925+
if (!packet)
926+
// Jump to the next iteration of this loop
927+
continue;
928+
924929
// Get the AVFrame from the current packet
925930
frame_finished = GetAVFrame();
926931

@@ -957,6 +962,11 @@ std::shared_ptr<Frame> FFmpegReader::ReadStream(int64_t requested_frame) {
957962
continue;
958963
}
959964

965+
// Packet may become NULL on Close inside Seek if CheckSeek returns false
966+
if (!packet)
967+
// Jump to the next iteration of this loop
968+
continue;
969+
960970
// Update PTS / Frame Offset (if any)
961971
UpdatePTSOffset(false);
962972

0 commit comments

Comments
 (0)