[libdvdnav-devel] [PATCH] src/dvd_reader.c: Fix a potential NULL dereference

Andrew Clayton andrew at digital-domain.net
Fri Oct 24 01:37:22 CEST 2014


In DVDOpen() one of the first things that is done is

    path = strdup(ppath);

path is then checked for NULL, if it is we jump to DVDOpen_error; where
the first thing done is to print en error message using path. This bit
of code is used as a general fall back so we don't want to stop
displaying path in the cases where it isn't NULL.

The simplest solution is to simply put a guard on it in the fprintf
statement, in the case that path is NULL use "" instead of path.

Signed-off-by: Andrew Clayton <andrew at digital-domain.net>
---
 src/dvd_reader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/dvd_reader.c b/src/dvd_reader.c
index fb045b3..80b567d 100644
--- a/src/dvd_reader.c
+++ b/src/dvd_reader.c
@@ -603,7 +603,7 @@ dvd_reader_t *DVDOpen( const char *ppath )
 
 DVDOpen_error:
   /* If it's none of the above, screw it. */
-  fprintf( stderr, "libdvdread: Could not open %s\n", path );
+  fprintf( stderr, "libdvdread: Could not open %s\n", (path) ? path : "");
   free( path );
   free( path_copy );
   if ( cdir >= 0 )
-- 
1.9.3



More information about the libdvdnav-devel mailing list