mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
avcodec/sheervideo: Don't leave context in inconsistent state upon error
This has happened if the format changed midstream and if the new packet is so small that it is instantaneously rejected: In this case the VLC tables were for the new format, although the context says that they are still the ones for the old format. It can also happen if the format changed midstream and the allocation of the new tables fails. If the next packet is a packet for the old format, the decoder thinks it already has the correct VLC tables, leading to a segfault. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit 8969b9aa061790a5e87694aab17741cc7647d099)
This commit is contained in:
parent
a7d3dc5b04
commit
9c6feb104d
@ -2036,17 +2036,18 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s->format != format) {
|
||||||
|
if (ret < 0) {
|
||||||
|
s->format = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
s->format = format;
|
||||||
|
}
|
||||||
if (avpkt->size < 20 + avctx->width * avctx->height / 16) {
|
if (avpkt->size < 20 + avctx->width * avctx->height / 16) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Input packet too small\n");
|
av_log(avctx, AV_LOG_ERROR, "Input packet too small\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->format != format) {
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
s->format = format;
|
|
||||||
}
|
|
||||||
|
|
||||||
p->pict_type = AV_PICTURE_TYPE_I;
|
p->pict_type = AV_PICTURE_TYPE_I;
|
||||||
p->key_frame = 1;
|
p->key_frame = 1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user