[FFmpeg-cvslog] avformat/dss: Use AV_DICT_DONT_STRDUP_VAL to save a malloc+memcpy

Andreas Rheinhardt git at videolan.org
Wed Mar 25 00:04:13 EET 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sun Nov 10 02:48:21 2019 +0100| [557668e8cbd9695cc45a1135e158b81b5c2b6496] | committer: Andreas Rheinhardt

avformat/dss: Use AV_DICT_DONT_STRDUP_VAL to save a malloc+memcpy

Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=557668e8cbd9695cc45a1135e158b81b5c2b6496
---

 libavformat/dss.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/libavformat/dss.c b/libavformat/dss.c
index 8e0b72fbe5..ae7a259526 100644
--- a/libavformat/dss.c
+++ b/libavformat/dss.c
@@ -103,15 +103,11 @@ static int dss_read_metadata_string(AVFormatContext *s, unsigned int offset,
 
     ret = avio_read(s->pb, value, size);
     if (ret < size) {
-        ret = ret < 0 ? ret : AVERROR_EOF;
-        goto exit;
+        av_free(value);
+        return ret < 0 ? ret : AVERROR_EOF;
     }
 
-    ret = av_dict_set(&s->metadata, key, value, 0);
-
-exit:
-    av_free(value);
-    return ret;
+    return av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL);
 }
 
 static int dss_read_header(AVFormatContext *s)



More information about the ffmpeg-cvslog mailing list