[libdvdnav-devel] [PATCH 1/2] dvdcss_open_stream: fix SEGFAULT due to a NULL psz_target

Thomas Guillem thomas at gllm.fr
Wed Jan 28 16:29:39 CET 2015


---
 src/device.c    | 2 +-
 src/libdvdcss.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/device.c b/src/device.c
index 2b82ae1..0a19fe8 100644
--- a/src/device.c
+++ b/src/device.c
@@ -190,7 +190,7 @@ void dvdcss_check_device ( dvdcss_t dvdcss )
 #endif
 
     /* If the device name is non-NULL or stream is set, return. */
-    if( dvdcss->psz_device[0] || dvdcss->p_stream )
+    if( (dvdcss->psz_device && dvdcss->psz_device[0]) || dvdcss->p_stream )
     {
         return;
     }
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 1b4c680..f2d9a22 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -495,7 +495,7 @@ static dvdcss_t dvdcss_open_common ( const char *psz_target, void *p_stream,
     /* Initialize structure with default values. */
     dvdcss->i_pos = 0;
     dvdcss->p_titles = NULL;
-    dvdcss->psz_device = strdup( psz_target );
+    dvdcss->psz_device = psz_target ? strdup( psz_target ) : NULL;
     dvdcss->psz_error = "no error";
     dvdcss->i_method = DVDCSS_METHOD_KEY;
     dvdcss->psz_cachefile[0] = '\0';
-- 
2.1.3



More information about the libdvdnav-devel mailing list