[FFmpeg-devel] [PATCH] avformat/http: Fix double-free on error

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Thu Jan 20 21:20:46 EET 2022


av_dict_set() with AV_DICT_DONT_STRDUP_VAL takes ownership
of the string it is passed to as val; this includes freeing it
on error.

Fixes Coverity issue #1497468.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
Untested.

 libavformat/http.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index cf04d3f14f..8b5fc3d2a4 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -335,10 +335,8 @@ static int redirect_cache_set(HTTPContext *s, const char *source, const char *de
     }
 
     ret = av_dict_set(&s->redirect_cache, source, value, AV_DICT_MATCH_CASE | AV_DICT_DONT_STRDUP_VAL);
-    if (ret < 0) {
-        av_free(value);
+    if (ret < 0)
         return ret;
-    }
 
     return 0;
 }
-- 
2.32.0



More information about the ffmpeg-devel mailing list