The AVPacket given to an encoder's encode callback is unreferenced generically on error.
Unified · Split
| @@ -280,17 +280,14 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 279 unmodified lines | |||
| 280 | // Check if subtraction resulted in an overflow | 280 | // Check if subtraction resulted in an overflow |
| 281 | if ((discard_padding < avctx->frame_size) != (avpkt->duration > 0)) { | 281 | if ((discard_padding < avctx->frame_size) != (avpkt->duration > 0)) { |
| 282 | av_log(avctx, AV_LOG_ERROR, "discard padding overflow\n"); | 282 | av_log(avctx, AV_LOG_ERROR, "discard padding overflow\n"); |
| 283 | av_packet_unref(avpkt); | ||
| 284 | return AVERROR(EINVAL); | 283 | return AVERROR(EINVAL); |
| 285 | } | 284 | } |
| 286 | if ((!s->delay_sent && avctx->initial_padding > 0) || discard_padding > 0) { | 285 | if ((!s->delay_sent && avctx->initial_padding > 0) || discard_padding > 0) { |
| 287 | uint8_t* side_data = av_packet_new_side_data(avpkt, | 286 | uint8_t* side_data = av_packet_new_side_data(avpkt, |
| 288 | AV_PKT_DATA_SKIP_SAMPLES, | 287 | AV_PKT_DATA_SKIP_SAMPLES, |
| 289 | 10); | 288 | 10); |
| 290 | if(!side_data) { | 289 | if (!side_data) |
| 291 | av_packet_unref(avpkt); | ||
| 292 | return AVERROR(ENOMEM); | 290 | return AVERROR(ENOMEM); |
| 293 | } | ||
| 294 | if (!s->delay_sent) { | 291 | if (!s->delay_sent) { |
| 295 | AV_WL32(side_data, avctx->initial_padding); | 292 | AV_WL32(side_data, avctx->initial_padding); |
| 296 | s->delay_sent = 1; | 293 | s->delay_sent = 1; |