[libdvdnav-devel] [PATCH 29/33] Check for malloc fail before setting buffer

beandog at gentoo.org beandog at gentoo.org
Thu Jan 15 21:45:41 CET 2015


From: Steve Dibb <steve.dibb at gmail.com>

---
 src/dvd_reader.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/dvd_reader.c b/src/dvd_reader.c
index 548aa65..a736ba6 100644
--- a/src/dvd_reader.c
+++ b/src/dvd_reader.c
@@ -1393,7 +1393,6 @@ int DVDDiscID( dvd_reader_t *dvd, unsigned char *discid )
       ssize_t bytes_read;
       ssize_t file_size = dvd_file->filesize * DVD_VIDEO_LB_LEN;
       char *buffer_base = malloc( file_size + 2048 );
-      char *buffer = (char *)(((uintptr_t)buffer_base & ~((uintptr_t)2047)) + 2048);
 
       if( buffer_base == NULL ) {
           DVDCloseFile( dvd_file );
@@ -1402,6 +1401,8 @@ int DVDDiscID( dvd_reader_t *dvd, unsigned char *discid )
           return -1;
       }
 
+      char *buffer = (char *)(((uintptr_t)buffer_base & ~((uintptr_t)2047)) + 2048);
+
       bytes_read = DVDReadBytes( dvd_file, buffer, file_size );
       if( bytes_read != file_size ) {
           fprintf( stderr, "libdvdread: DVDDiscId read returned %zd bytes"
-- 
2.0.4



More information about the libdvdnav-devel mailing list