[libdvdnav-devel] [PATCH 27/33] Check for malloc fail before setting secbuf

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


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

---
 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 3dff649..e22412a 100644
--- a/src/dvd_reader.c
+++ b/src/dvd_reader.c
@@ -1323,12 +1323,12 @@ ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size )
     ( ( ( seek_byte + byte_size ) % DVD_VIDEO_LB_LEN ) ? 1 : 0 );
 
   secbuf_base = malloc( numsec * DVD_VIDEO_LB_LEN + 2048 );
-  secbuf = (unsigned char *)(((uintptr_t)secbuf_base & ~((uintptr_t)2047)) + 2048);
   if( !secbuf_base ) {
     fprintf( stderr, "libdvdread: Can't allocate memory "
              "for file read!\n" );
     return 0;
   }
+  secbuf = (unsigned char *)(((uintptr_t)secbuf_base & ~((uintptr_t)2047)) + 2048);
 
   if( dvd_file->dvd->isImageFile ) {
     ret = DVDReadBlocksUDF( dvd_file, (uint32_t) seek_sector,
-- 
2.0.4



More information about the libdvdnav-devel mailing list