diff mbox series

[FFmpeg-devel,06/10] avcodec/exif: Avoid allocation for small buffer

Message ID 20210123204800.689497-6-andreas.rheinhardt@gmail.com
State Accepted
Commit f15477169ea9947336448af2772087c8fa1c6cdf
Headers show
Series [FFmpeg-devel,01/10] avcodec/atrac3plus_data: Remove unused arrays
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 Jan. 23, 2021, 8:47 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/exif.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/exif.c b/libavcodec/exif.c
index 2874772db4..0b656fd09b 100644
--- a/libavcodec/exif.c
+++ b/libavcodec/exif.c
@@ -95,22 +95,15 @@  static int exif_decode_tag(void *logctx, GetByteContext *gbytes, int le,
         ret = ff_exif_decode_ifd(logctx, gbytes, le, depth + 1, metadata);
     } else {
         const char *name = exif_get_tag_name(id);
-        char *use_name   = (char*) name;
-
-        if (!use_name) {
-            use_name = av_malloc(7);
-            if (!use_name) {
-                return AVERROR(ENOMEM);
-            }
-            snprintf(use_name, 7, "0x%04X", id);
-        }
-
-        ret = exif_add_metadata(logctx, count, type, use_name, NULL,
-                                gbytes, le, metadata);
+        char buf[7];
 
         if (!name) {
-            av_freep(&use_name);
+            name = buf;
+            snprintf(buf, sizeof(buf), "0x%04X", id);
         }
+
+        ret = exif_add_metadata(logctx, count, type, name, NULL,
+                                gbytes, le, metadata);
     }
 
     bytestream2_seek(gbytes, cur_pos, SEEK_SET);