After the AVFrame has been wrapped into a buffer, it is owned by the buffer and must not be freed manually any more. Yet this happens on subsequent errors. This bug was introduced in 6ca43a9675d651d7ea47c7ba2fafb1bf831c4d0b.
Unified · Split
| @@ -365,7 +365,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) · 364 unmodified lines | |||
| 365 | LavfiContext *lavfi = avctx->priv_data; | 365 | LavfiContext *lavfi = avctx->priv_data; |
| 366 | double min_pts = DBL_MAX; | 366 | double min_pts = DBL_MAX; |
| 367 | int stream_idx, min_pts_sink_idx = 0; | 367 | int stream_idx, min_pts_sink_idx = 0; |
| 368 | AVFrame *frame; | 368 | AVFrame *frame, *frame_to_free; |
| 369 | AVDictionary *frame_metadata; | 369 | AVDictionary *frame_metadata; |
| 370 | int ret, i; | 370 | int ret, i; |
| 371 | AVStream *st; | 371 | AVStream *st; |
| @@ -378,6 +378,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) · 6 unmodified lines | |||
| 378 | frame = av_frame_alloc(); | 378 | frame = av_frame_alloc(); |
| 379 | if (!frame) | 379 | if (!frame) |
| 380 | return AVERROR(ENOMEM); | 380 | return AVERROR(ENOMEM); |
| 381 | frame_to_free = frame; | ||
| 381 | 382 | ||
| 382 | /* iterate through all the graph sinks. Select the sink with the | 383 | /* iterate through all the graph sinks. Select the sink with the |
| 383 | * minimum PTS */ | 384 | * minimum PTS */ |
| @@ -423,6 +424,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) · 39 unmodified lines | |||
| 423 | ret = AVERROR(ENOMEM); | 424 | ret = AVERROR(ENOMEM); |
| 424 | goto fail; | 425 | goto fail; |
| 425 | } | 426 | } |
| 427 | frame_to_free = NULL; | ||
| 426 | 428 | ||
| 427 | pkt->data = pkt->buf->data; | 429 | pkt->data = pkt->buf->data; |
| 428 | pkt->size = pkt->buf->size; | 430 | pkt->size = pkt->buf->size; |
| @@ -463,12 +465,11 @@ FF_DISABLE_DEPRECATION_WARNINGS · 34 unmodified lines | |||
| 463 | FF_ENABLE_DEPRECATION_WARNINGS | 465 | FF_ENABLE_DEPRECATION_WARNINGS |
| 464 | #endif | 466 | #endif |
| 465 | 467 | ||
| 466 | if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) | 468 | av_frame_free(&frame_to_free); |
| 467 | av_frame_free(&frame); | ||
| 468 | 469 | ||
| 469 | return pkt->size; | 470 | return pkt->size; |
| 470 | fail: | 471 | fail: |
| 471 | av_frame_free(&frame); | 472 | av_frame_free(&frame_to_free); |
| 472 | return ret; | 473 | return ret; |
| 473 | 474 | ||
| 474 | } | 475 | } |