diff mbox series

[FFmpeg-devel,2/3] avcodec/pngdec: Don't use AVBPrint where inappropriate

Message ID 20210317163202.672493-2-andreas.rheinhardt@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/3] avcodec/pngdec: Use internal AVBPrint string when parsing chunks
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt March 17, 2021, 4:32 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/pngdec.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 6b9fdf5a22..21e79a24a7 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -1338,17 +1338,13 @@  static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
             break;
         }
         case MKTAG('g', 'A', 'M', 'A'): {
-            AVBPrint bp;
-            char *gamma_str;
+            char gamma_str[18];
             int num = bytestream2_get_be32(&s->gb);
 
-            av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
-            av_bprintf(&bp, "%i/%i", num, 100000);
-            ret = av_bprint_finalize(&bp, &gamma_str);
-            if (ret < 0)
-                return ret;
+            snprintf(gamma_str, sizeof(gamma_str), "%i/100000", num);
 
-            av_dict_set(&p->metadata, "gamma", gamma_str, AV_DICT_DONT_STRDUP_VAL);
+            if ((ret = av_dict_set(&p->metadata, "gamma", gamma_str, 0)) < 0)
+                return ret;
 
             bytestream2_skip(&s->gb, 4); /* crc */
             break;