[FFmpeg-devel] [PATCH] lavc/avpacket: forward av_buffer_realloc() error code.
James Almer
jamrial at gmail.com
Sun Aug 9 16:56:33 EEST 2020
On 1/4/2020 4:00 PM, Nicolas George wrote:
> Fix CID 1457229.
>
> Signed-off-by: Nicolas George <george at nsup.org>
> ---
> libavcodec/avpacket.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
> index 858f827a0a..4da832c53c 100644
> --- a/libavcodec/avpacket.c
> +++ b/libavcodec/avpacket.c
> @@ -170,7 +170,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
> #define ALLOC_MALLOC(data, size) data = av_malloc(size)
> #define ALLOC_BUF(data, size) \
> do { \
> - av_buffer_realloc(&pkt->buf, size); \
> + ret = av_buffer_realloc(&pkt->buf, size); \
> data = pkt->buf ? pkt->buf->data : NULL; \
> } while (0)
>
> @@ -197,6 +197,8 @@ do { \
> /* Makes duplicates of data, side_data, but does not copy any other fields */
> static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
> {
> + int ret = AVERROR_BUG;
> +
> pkt->data = NULL;
> pkt->side_data = NULL;
> pkt->side_data_elems = 0;
> @@ -220,7 +222,8 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
>
> failed_alloc:
> av_packet_unref(pkt);
> - return AVERROR(ENOMEM);
> + av_assert1(ret != AVERROR_BUG);
> + return ret;
> }
>
> int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
This code is deprecated and will be removed in the next major bump, so
IMO it's worth trying to fix it, and especially if it's just to silence
a static analyzer.
More information about the ffmpeg-devel
mailing list