[FFmpeg-devel] [PATCH] lavc/pngdec: fix av_bprint_finalize() usage.

Rostislav Pehlivanov atomnuker at gmail.com
Thu Nov 9 15:06:41 EET 2017


On 9 November 2017 at 08:49, Nicolas George <george at nsup.org> wrote:

> Signed-off-by: Nicolas George <george at nsup.org>
> ---
>  libavcodec/pngdec.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> index 20707f0ae5..1d72f9542a 100644
> --- a/libavcodec/pngdec.c
> +++ b/libavcodec/pngdec.c
> @@ -524,9 +524,9 @@ static int decode_text_chunk(PNGDecContext *s,
> uint32_t length, int compressed,
>          if ((ret = decode_zbuf(&bp, data, data_end)) < 0)
>              return ret;
>          text_len = bp.len;
> -        av_bprint_finalize(&bp, (char **)&text);
> -        if (!text)
> -            return AVERROR(ENOMEM);
> +        ret = av_bprint_finalize(&bp, (char **)&text);
> +        if (ret < 0)
> +            return ret;
>      } else {
>          text = (uint8_t *)data;
>          text_len = data_end - text;
> @@ -862,9 +862,9 @@ static int decode_iccp_chunk(PNGDecContext *s, int
> length, AVFrame *f)
>      if ((ret = decode_zbuf(&bp, s->gb.buffer, s->gb.buffer + length)) < 0)
>          return ret;
>
> -    av_bprint_finalize(&bp, (char **)&data);
> -    if (!data)
> -        return AVERROR(ENOMEM);
> +    ret = av_bprint_finalize(&bp, (char **)&data);
> +    if (ret < 0)
> +        return ret;
>
>      sd = av_frame_new_side_data(f, AV_FRAME_DATA_ICC_PROFILE, bp.len);
>      if (!sd) {
> @@ -1317,9 +1317,9 @@ static int decode_frame_common(AVCodecContext
> *avctx, PNGDecContext *s,
>
>              av_bprint_init(&bp, 0, -1);
>              av_bprintf(&bp, "%i/%i", num, 100000);
> -            av_bprint_finalize(&bp, &gamma_str);
> -            if (!gamma_str)
> -                return AVERROR(ENOMEM);
> +            ret = av_bprint_finalize(&bp, &gamma_str);
> +            if (ret < 0)
> +                return ret;
>
>              av_dict_set(&p->metadata, "gamma", gamma_str,
> AV_DICT_DONT_STRDUP_VAL);
>
> --
> 2.14.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


Its not really a fix since bprint can't return non-ENOMEM. All were copied
from one place in the code.
Aside from that LGTM


More information about the ffmpeg-devel mailing list