diff options
author | Anton Khirnov <anton@khirnov.net> | 2016-10-26 13:41:12 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-12-14 09:06:44 +0100 |
commit | 549d0bdca53af7a6e0c612ab4b03baecf3a5878f (patch) | |
tree | c9b90d376f74d82b8b5bc95e7c06423b14b915e0 /libavcodec/utils.c | |
parent | 47e547b321338c73c21fa623789f1efbd80a297a (diff) |
decode: be more explicit about storing the last packet properties
The current code stores a pointer to the packet passed to the decoder,
which is then used during get_buffer() for timestamps and side data
passthrough. However, since this is a pointer to user data which we do
not own, storing it is potentially dangerous. It is also ill defined for
the new decoding API with split input/output.
Fix this problem by making an explicit internally owned copy of the
packet properties.
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 5350eb819a..b569b48f7a 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -433,6 +433,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code goto free_and_end; } + avctx->internal->last_pkt_props = av_packet_alloc(); + if (!avctx->internal->last_pkt_props) { + ret = AVERROR(ENOMEM); + goto free_and_end; + } + if (codec->priv_data_size > 0) { if (!avctx->priv_data) { avctx->priv_data = av_mallocz(codec->priv_data_size); @@ -713,6 +719,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_frame_free(&avctx->internal->to_free); av_frame_free(&avctx->internal->buffer_frame); av_packet_free(&avctx->internal->buffer_pkt); + av_packet_free(&avctx->internal->last_pkt_props); av_freep(&avctx->internal->pool); } av_freep(&avctx->internal); @@ -753,6 +760,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) av_frame_free(&avctx->internal->to_free); av_frame_free(&avctx->internal->buffer_frame); av_packet_free(&avctx->internal->buffer_pkt); + av_packet_free(&avctx->internal->last_pkt_props); for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++) av_buffer_pool_uninit(&pool->pools[i]); av_freep(&avctx->internal->pool); |