[libdvdcss-devel] dvdcss_open_stream: fix SEGFAULT due to a NULL psz_target

[email protected] (Thomas Guillem) Wed, 28 Jan 2015 16:33:51 +0100 (CET)
Newsgroups gmane.comp.video.videolan.libdvdcss,gmane.comp.video.videolan.libdvdcss.devel
Message-ID <[email protected]>
libdvdcss | branch: master | Thomas Guillem <[email protected]> | Wed Jan 28 16:29:39 2015 +0100| [cce6baf1edf30fd39650eea94e752f5be515feb9] | committer: Jean-Baptiste Kempf

dvdcss_open_stream: fix SEGFAULT due to a NULL psz_target

Signed-off-by: Jean-Baptiste Kempf <[email protected]>

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

 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';

_______________________________________________
libdvdcss-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/libdvdcss-devel