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 | 365 | LavfiContext *lavfi = avctx->priv_data; |
| 366 | 366 | double min_pts = DBL_MAX; |
| 367 | 367 | int stream_idx, min_pts_sink_idx = 0; |
| 368 | − AVFrame *frame; | |
| 368 | + AVFrame *frame, *frame_to_free; | |
| 369 | 369 | AVDictionary *frame_metadata; |
| 370 | 370 | int ret, i; |
| 371 | 371 | AVStream *st; |
| @@ -378,6 +378,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) · 6 unmodified lines | ||
| 378 | 378 | frame = av_frame_alloc(); |
| 379 | 379 | if (!frame) |
| 380 | 380 | return AVERROR(ENOMEM); |
| 381 | + frame_to_free = frame; | |
| 381 | 382 | |
| 382 | 383 | /* iterate through all the graph sinks. Select the sink with the |
| 383 | 384 | * minimum PTS */ |
| @@ -423,6 +424,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) · 39 unmodified lines | ||
| 423 | 424 | ret = AVERROR(ENOMEM); |
| 424 | 425 | goto fail; |
| 425 | 426 | } |
| 427 | + frame_to_free = NULL; | |
| 426 | 428 | |
| 427 | 429 | pkt->data = pkt->buf->data; |
| 428 | 430 | pkt->size = pkt->buf->size; |
| @@ -463,12 +465,11 @@ FF_DISABLE_DEPRECATION_WARNINGS · 34 unmodified lines | ||
| 463 | 465 | FF_ENABLE_DEPRECATION_WARNINGS |
| 464 | 466 | #endif |
| 465 | 467 | |
| 466 | − if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) | |
| 467 | − av_frame_free(&frame); | |
| 468 | + av_frame_free(&frame_to_free); | |
| 468 | 469 | |
| 469 | 470 | return pkt->size; |
| 470 | 471 | fail: |
| 471 | − av_frame_free(&frame); | |
| 472 | + av_frame_free(&frame_to_free); | |
| 472 | 473 | return ret; |
| 473 | 474 | |
| 474 | 475 | } |