summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-01-23 15:44:50 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-01-26 13:56:59 +0100
commitf15477169ea9947336448af2772087c8fa1c6cdf (patch)
treefa6a8742c3b1b585b318111498500e5f41416811 /libavcodec
parent458acb61fa2aecc2a5a71836841af3a43d28e560 (diff)
avcodec/exif: Avoid allocation for small buffer
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/exif.c19
1 files changed, 6 insertions, 13 deletions
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);