diff options
author | James Almer <jamrial@gmail.com> | 2019-11-10 02:08:17 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2019-11-14 18:30:51 +0300 |
commit | 73ee53f317418a5719f6169e6171b40f90d18321 (patch) | |
tree | 2ebf4ef50052208fe00047c49558f40302aeb2a5 /libavcodec/encode.c | |
parent | f01f9f179389befe9bce7639088e453146a39915 (diff) |
avcodec/encode: add missing assert to avcodec_receive_packet()
Encoders must return reference counted packets.
This was checked only for encoders using the AVCodec->encode2() API, while
blindly accepting whatever encoders using the AVCodec->receive_packet() API
were returning.
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/encode.c')
-rw-r--r-- | libavcodec/encode.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libavcodec/encode.c b/libavcodec/encode.c index d81b32b983..9ed2cf0f59 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -428,9 +428,15 @@ int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket * return AVERROR(EINVAL); if (avctx->codec->receive_packet) { + int ret; if (avctx->internal->draining && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) return AVERROR_EOF; - return avctx->codec->receive_packet(avctx, avpkt); + ret = avctx->codec->receive_packet(avctx, avpkt); + if (!ret) + // Encoders must always return ref-counted buffers. + // Side-data only packets have no data and can be not ref-counted. + av_assert0(!avpkt->data || avpkt->buf); + return ret; } // Emulation via old API. |