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).
This commit is contained in:
SuslikV
2019-07-30 21:30:09 +03:00
committed by GitHub
parent 04d1a5849a
commit bacd46df33

View File

@@ -921,6 +921,11 @@ std::shared_ptr<Frame> FFmpegReader::ReadStream(int64_t requested_frame) {
continue;
}
// Packet may become NULL on Close inside Seek if CheckSeek returns false
if (!packet)
// Jump to the next iteration of this loop
continue;
// Get the AVFrame from the current packet
frame_finished = GetAVFrame();
@@ -957,6 +962,11 @@ std::shared_ptr<Frame> FFmpegReader::ReadStream(int64_t requested_frame) {
continue;
}
// Packet may become NULL on Close inside Seek if CheckSeek returns false
if (!packet)
// Jump to the next iteration of this loop
continue;
// Update PTS / Frame Offset (if any)
UpdatePTSOffset(false);