summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2016-01-01 20:23:37 +0100
committerHendrik Leppkes <h.leppkes@gmail.com>2016-01-02 09:27:51 +0100
commitb966a403dd80604bb7dbb9ee6ec331ade0e84953 (patch)
tree36787f23563fd49f69b85402eeba38a2ecbedd54 /libavformat/utils.c
parentdbfb2c1abfe8f70ed958d84039f20cf3409c05ec (diff)
avcodec/utils: fix AVPacket lifetime in seek_frame_generic
Fixes ticket #5117
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 95acbf3251..76065023ad 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2142,15 +2142,18 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index,
} while (read_status == AVERROR(EAGAIN));
if (read_status < 0)
break;
- av_packet_unref(&pkt);
if (stream_index == pkt.stream_index && pkt.dts > timestamp) {
- if (pkt.flags & AV_PKT_FLAG_KEY)
+ if (pkt.flags & AV_PKT_FLAG_KEY) {
+ av_packet_unref(&pkt);
break;
+ }
if (nonkey++ > 1000 && st->codec->codec_id != AV_CODEC_ID_CDGRAPHICS) {
av_log(s, AV_LOG_ERROR,"seek_frame_generic failed as this stream seems to contain no keyframes after the target timestamp, %d non keyframes found\n", nonkey);
+ av_packet_unref(&pkt);
break;
}
}
+ av_packet_unref(&pkt);
}
index = av_index_search_timestamp(st, timestamp, flags);
}