aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2012-04-08 12:09:55 +0200
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2012-04-08 13:06:13 +0200
commit069cf86d32103da7bb2a0581dcbf66f1e95508d5 (patch)
treec51096ab171bcc5bc132626c60ea9f21581209d0 /libavcodec/utils.c
parentcb939468202ce9352a9a8809007f24608bbbb61a (diff)
downloadffmpeg-069cf86d32103da7bb2a0581dcbf66f1e95508d5.tar.gz
Fix side-data memleak also for audio.
This uses the same code as in decode_video also in decode_audio. Should fix valgrind FATE failures for nellymoser encode test. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index e63878d2c7..ab34b40c62 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1508,7 +1508,7 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa
int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
AVFrame *frame,
int *got_frame_ptr,
- AVPacket *avpkt)
+ const AVPacket *avpkt)
{
int ret = 0;
@@ -1524,17 +1524,23 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
}
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
- av_packet_split_side_data(avpkt);
- apply_param_change(avctx, avpkt);
+ // copy to ensure we do not change avpkt
+ AVPacket tmp = *avpkt;
+ int did_split = av_packet_split_side_data(&tmp);
+ apply_param_change(avctx, &tmp);
- avctx->pkt = avpkt;
- ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
+ avctx->pkt = &tmp;
+ ret = avctx->codec->decode(avctx, frame, got_frame_ptr, &tmp);
if (ret >= 0 && *got_frame_ptr) {
avctx->frame_number++;
frame->pkt_dts = avpkt->dts;
if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt;
}
+
+ avctx->pkt = NULL;
+ if (did_split)
+ ff_packet_free_side_data(&tmp);
}
return ret;
}