@@ -462,12 +462,15 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
AVIOContext *pb = s->pb;
WtvContext *wctx = s->priv_data;
AVStream *st = s->streams[pkt->stream_index];
+ int ret;
if (st->codecpar->codec_id == AV_CODEC_ID_MJPEG && !wctx->thumbnail.size) {
- av_packet_ref(&wctx->thumbnail, pkt);
+ ret = av_packet_ref(&wctx->thumbnail, pkt);
+ if (ret < 0)
+ return ret;
return 0;
} else if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
- int ret = ff_check_h264_startcode(s, st, pkt);
+ ret = ff_check_h264_startcode(s, st, pkt);
if (ret < 0)
return ret;
}