[libdvdnav-devel] dvd_reader: check malloc return
Jean-Baptiste Kempf
git at videolan.org
Thu Jan 9 12:08:33 CET 2014
libdvdread | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Jan 9 12:05:10 2014 +0100| [e601338843ba3d98c1df474446a2ffcbae5e7812] | committer: Jean-Baptiste Kempf
dvd_reader: check malloc return
> http://git.videolan.org/gitweb.cgi/libdvdread.git/?a=commit;h=e601338843ba3d98c1df474446a2ffcbae5e7812
---
src/dvd_reader.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/dvd_reader.c b/src/dvd_reader.c
index cadc697..83f50d8 100644
--- a/src/dvd_reader.c
+++ b/src/dvd_reader.c
@@ -298,6 +298,7 @@ static char *sun_block2char( const char *path )
/* Replace "/dsk/" with "/rdsk/" */
new_path = malloc( strlen(path) + 2 );
+ if(!new_path) return NULL;
strcpy( new_path, path );
strcpy( strstr( new_path, "/dsk/" ), "" );
strcat( new_path, "/rdsk/" );
@@ -329,6 +330,7 @@ static char *bsd_block2char( const char *path )
/* Replace "/dev/" with "/dev/r" */
new_path = malloc( strlen(path) + 2 );
+ if(!new_path) return NULL;
strcpy( new_path, "/dev/r" );
strcat( new_path, path + strlen( "/dev/" ) );
@@ -404,6 +406,8 @@ dvd_reader_t *DVDOpen( const char *ppath )
#else
dev_name = strdup( path );
#endif
+ if(!dev_name)
+ goto DVDOpen_error;
dvd = DVDOpenImageFile( dev_name, have_css );
free( dev_name );
free(path);
More information about the libdvdnav-devel
mailing list