Fixes 'ffprobe 1_poc.mp4' segfault introduced with commit 0021484d05f9b0f032fa319399de6e24eea0c04f codec_close should not assume that the codec_id did not change.
Unified · Split
| @@ -1292,9 +1292,15 @@ static int codec_close(FFStream *sti) · 1291 unmodified lines | |||
| 1292 | { | 1292 | { |
| 1293 | AVCodecContext *avctx_new = NULL; | 1293 | AVCodecContext *avctx_new = NULL; |
| 1294 | AVCodecParameters *par_tmp = NULL; | 1294 | AVCodecParameters *par_tmp = NULL; |
| 1295 | const AVCodec *new_codec = NULL; | ||
| 1295 | int ret; | 1296 | int ret; |
| 1296 | 1297 | ||
| 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); | ||
| 1298 | if (!avctx_new) { | 1304 | if (!avctx_new) { |
| 1299 | ret = AVERROR(ENOMEM); | 1305 | ret = AVERROR(ENOMEM); |
| 1300 | goto fail; | 1306 | goto fail; |