[FFmpeg-cvslog] avformat/avio: Avoid av_strdup(NULL)

Andreas Rheinhardt git at videolan.org
Tue Mar 5 13:13:35 EET 2024


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat Mar  2 19:59:09 2024 +0100| [fed46d77062755a8488144071239aaf00fc5a8b9] | committer: Andreas Rheinhardt

avformat/avio: Avoid av_strdup(NULL)

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

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

 libavformat/avio.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index f3d10fac39..5186c2b464 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -436,15 +436,19 @@ int ffio_fdopen(AVIOContext **sp, URLContext *h)
         return AVERROR(ENOMEM);
     }
     s = *sp;
-    s->protocol_whitelist = av_strdup(h->protocol_whitelist);
-    if (!s->protocol_whitelist && h->protocol_whitelist) {
-        avio_closep(sp);
-        return AVERROR(ENOMEM);
+    if (h->protocol_whitelist) {
+        s->protocol_whitelist = av_strdup(h->protocol_whitelist);
+        if (!s->protocol_whitelist) {
+            avio_closep(sp);
+            return AVERROR(ENOMEM);
+        }
     }
-    s->protocol_blacklist = av_strdup(h->protocol_blacklist);
-    if (!s->protocol_blacklist && h->protocol_blacklist) {
-        avio_closep(sp);
-        return AVERROR(ENOMEM);
+    if (h->protocol_blacklist) {
+        s->protocol_blacklist = av_strdup(h->protocol_blacklist);
+        if (!s->protocol_blacklist) {
+            avio_closep(sp);
+            return AVERROR(ENOMEM);
+        }
     }
     s->direct = h->flags & AVIO_FLAG_DIRECT;
 



More information about the ffmpeg-cvslog mailing list