[libav-commits] lavf: don't segfault when a NULL filename is passed to avformat_open_input( )

Anton Khirnov git at libav.org
Sat Oct 6 09:43:30 CEST 2012

Module: libav
Branch: release/0.7
Commit: 77d43bf42d76a1a3ccd8ea25937664c7f9d4bcac

Author:    Anton Khirnov <anton at khirnov.net>
Committer: Anton Khirnov <anton at khirnov.net>
Date:      Fri Jun 15 19:58:11 2012 +0200

lavf: don't segfault when a NULL filename is passed to avformat_open_input()

This can easily happen when the caller is using a custom AVIOContext.

Behave as if the filename was an empty string in this case.

CC: libav-stable at libav.org
(cherry picked from commit a5db8e4a1a5449cc7a61e963c9fa698a4f22131b)

Signed-off-by: Anton Khirnov <anton at khirnov.net>
(cherry picked from commit 7124fa5d3640e5b8089dd13b22a09038b2ec5216)

Signed-off-by: Anton Khirnov <anton at khirnov.net>


 libavformat/utils.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 57fc836..5f3da49 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -622,7 +622,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma
     s->duration = s->start_time = AV_NOPTS_VALUE;
-    av_strlcpy(s->filename, filename, sizeof(s->filename));
+    av_strlcpy(s->filename, filename ? filename : "", sizeof(s->filename));
     /* allocate private data */
     if (s->iformat->priv_data_size > 0) {

More information about the libav-commits mailing list