diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 25eabdb215..557258d839 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -365,8 +365,13 @@ int av_packet_ref(AVPacket *dst, AVPacket *src) if (ret < 0) goto fail; memcpy(dst->buf->data, src->data, src->size); - } else + } else { dst->buf = av_buffer_ref(src->buf); + if (!dst->buf) { + ret = AVERROR(ENOMEM); + goto fail; + } + } dst->size = src->size; dst->data = dst->buf->data;