Commit 05c4e138 authored by Steve Dibb's avatar Steve Dibb Committed by Jean-Baptiste Kempf

Check for malloc fail before setting buffer

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent a3d56905
...@@ -1393,7 +1393,6 @@ int DVDDiscID( dvd_reader_t *dvd, unsigned char *discid ) ...@@ -1393,7 +1393,6 @@ int DVDDiscID( dvd_reader_t *dvd, unsigned char *discid )
ssize_t bytes_read; ssize_t bytes_read;
ssize_t file_size = dvd_file->filesize * DVD_VIDEO_LB_LEN; ssize_t file_size = dvd_file->filesize * DVD_VIDEO_LB_LEN;
char *buffer_base = malloc( file_size + 2048 ); char *buffer_base = malloc( file_size + 2048 );
char *buffer = (char *)(((uintptr_t)buffer_base & ~((uintptr_t)2047)) + 2048);
if( buffer_base == NULL ) { if( buffer_base == NULL ) {
DVDCloseFile( dvd_file ); DVDCloseFile( dvd_file );
...@@ -1402,6 +1401,8 @@ int DVDDiscID( dvd_reader_t *dvd, unsigned char *discid ) ...@@ -1402,6 +1401,8 @@ int DVDDiscID( dvd_reader_t *dvd, unsigned char *discid )
return -1; return -1;
} }
char *buffer = (char *)(((uintptr_t)buffer_base & ~((uintptr_t)2047)) + 2048);
bytes_read = DVDReadBytes( dvd_file, buffer, file_size ); bytes_read = DVDReadBytes( dvd_file, buffer, file_size );
if( bytes_read != file_size ) { if( bytes_read != file_size ) {
fprintf( stderr, "libdvdread: DVDDiscId read returned %zd bytes" fprintf( stderr, "libdvdread: DVDDiscId read returned %zd bytes"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment