History

avformat/demux: Fix segfault due to avcodec_open2 failure

Fixes 'ffprobe 1_poc.mp4' segfault introduced with commit 0021484d05f9b0f032fa319399de6e24eea0c04f codec_close should not assume that the codec_id did not change.

Pavel Koshevoy committed 1 year ago

Commit 59a66601 parent 18c62241 file · +7 −1Browse files

Unified · Split

libavformat/demux.c+7−1
@@ -1292,9 +1292,15 @@ static int codec_close(FFStream *sti) · 1291 unmodified lines
12921292 {
12931293 AVCodecContext *avctx_new = NULL;
12941294 AVCodecParameters *par_tmp = NULL;
1295+ const AVCodec *new_codec = NULL;
12951296 int ret;
12961297
1297− avctx_new = avcodec_alloc_context3(sti->avctx->codec);
1298+ new_codec =
1299+ (sti->avctx->codec_id != sti->pub.codecpar->codec_id) ?
1300+ avcodec_find_decoder(sti->pub.codecpar->codec_id) :
1301+ sti->avctx->codec;
1302+
1303+ avctx_new = avcodec_alloc_context3(new_codec);
12981304 if (!avctx_new) {
12991305 ret = AVERROR(ENOMEM);
13001306 goto fail;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t