[libdvdnav-devel] [Git][videolan/libdvdread][master] 6 commits: dvdread: null check the reader allocation in DVDOpenCommon

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon Jun 29 21:08:04 UTC 2026



Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdread


Commits:
219682bb by Saifelden Mohamed Ismail at 2026-06-29T23:48:12+03:00
dvdread: null check the reader allocation in DVDOpenCommon

- - - - -
aec928eb by Saifelden Mohamed Ismail at 2026-06-29T23:48:12+03:00
dvdread: handle a failed input open in DVDOpenVOBPath

- - - - -
adcb7ecf by Saifelden Mohamed Ismail at 2026-06-29T23:48:12+03:00
dvdread: null check the file in DVDCloseFile

- - - - -
b9bb8b1c by Saifelden Mohamed Ismail at 2026-06-29T23:48:12+03:00
dvdread: close the mkb file in cppm_get_mkb_or_backup

- - - - -
98f82356 by Saifelden Mohamed Ismail at 2026-06-30T00:02:59+03:00
dvdread: byteswap the DVD-VR cell entry point times

- - - - -
5387735e by Saifelden Mohamed Ismail at 2026-06-30T00:03:16+03:00
dvdread: free the second track info table in ifoClose

- - - - -


2 changed files:

- src/dvd_reader.c
- src/ifo_read.c


Changes:

=====================================
src/dvd_reader.c
=====================================
@@ -435,9 +435,9 @@ static dvd_reader_t *DVDOpenCommon( void *priv,
   char *dev_name = NULL;
   char *path = NULL, *new_path = NULL, *path_copy = NULL;
   dvd_reader_t *ctx = calloc(1, sizeof(*ctx));
-  ctx->dvd_type = type;
   if(!ctx)
       return NULL;
+  ctx->dvd_type = type;
 
   ctx->priv = priv;
   if(logcb)
@@ -1076,20 +1076,27 @@ static uint8_t *cppm_get_mkb_or_backup( dvd_reader_t *ctx, int backup )
     return NULL;
 
   p_mkb = malloc( mkb_file->filesize * DVD_VIDEO_LB_LEN );
-  if ( !p_mkb )
+  if ( !p_mkb ) {
+    DVDCloseFile( mkb_file );
     return NULL;
+  }
 
-  if ( !DVDReadBytes( mkb_file, p_mkb, mkb_file->filesize * DVD_VIDEO_LB_LEN ) ) 
+  if ( !DVDReadBytes( mkb_file, p_mkb, mkb_file->filesize * DVD_VIDEO_LB_LEN ) )
   {
     free( p_mkb );
+    DVDCloseFile( mkb_file );
     return NULL;
   }
 
   /* checking header */
   if( ( !memcmp( p_mkb, "DVDAUDIO.MKB", 12 ) && !backup )
-        || ( !memcmp( p_mkb, "DVDAUDIO.BUP", 12 ) && backup ) )
+        || ( !memcmp( p_mkb, "DVDAUDIO.BUP", 12 ) && backup ) ) {
+    free( p_mkb );
+    DVDCloseFile( mkb_file );
     return NULL;
+  }
 
+  DVDCloseFile( mkb_file );
   return p_mkb;
 }
 
@@ -1279,8 +1286,10 @@ static dvd_file_t *DVDOpenVOBPath( dvd_reader_t *ctx, int title, int menu )
           break;
         }
 
-        dvd_file->title_sizes[ i ] = BYTES_TO_DVD_BLOCKS_CEIL(fileinfo.size);
         dvd_file->title_devs[ i ] = dvdinput_open( ctx->priv, &ctx->logcb, full_path, NULL, ctx->fs );
+        if( !dvd_file->title_devs[ i ] )
+          break;
+        dvd_file->title_sizes[ i ] = BYTES_TO_DVD_BLOCKS_CEIL(fileinfo.size);
         /* setting type of stream will determine what decryption to use */
         dvdinput_set_stream( dvd_file->title_devs[ i ], stream_type );
 
@@ -1402,8 +1411,11 @@ dvd_file_t *DVDOpenFile( dvd_reader_t *ctx, int titlenum,
 
 void DVDCloseFile( dvd_file_t *dvd_file )
 {
-  dvd_reader_device_t *dvd = dvd_file->ctx->rd;
-  if( dvd_file && dvd ) {
+  dvd_reader_device_t *dvd;
+  if( !dvd_file )
+    return;
+  dvd = dvd_file->ctx->rd;
+  if( dvd ) {
     if( !dvd->isImageFile ) {
       int i;
 


=====================================
src/ifo_read.c
=====================================
@@ -821,6 +821,10 @@ void ifoClose(ifo_handle_t *ifofile) {
         free(ifofile->info_table_first_sector->tracks_info);
         free(ifofile->info_table_first_sector);
       }
+      if(ifofile->info_table_second_sector){
+        free(ifofile->info_table_second_sector->tracks_info);
+        free(ifofile->info_table_second_sector);
+      }
       if(ifofile->atsi_title_table)
         ifoFree_TT(ifofile);
       break;
@@ -1715,7 +1719,7 @@ int ifoRead_UD_PGCIT(ifo_handle_t *ifofile) {
         goto fail4;
       }
 
-      for( int j = 0; j > ud_pgcit->m_c_gi[j].c_epi_n; j++){
+      for( int j = 0; j < ud_pgcit->m_c_gi[i].c_epi_n; j++){
         B2N_32(ud_pgcit->m_c_gi[i].m_c_epi[j].ep_ptm.ptm);
         B2N_16(ud_pgcit->m_c_gi[i].m_c_epi[j].ep_ptm.ptm_extra);
       }



View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/98685cddcc23b45ef38af3bc9844f115b7f5c970...5387735ea66d76624f9c421b29f4167fc6f1abff

-- 
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/98685cddcc23b45ef38af3bc9844f115b7f5c970...5387735ea66d76624f9c421b29f4167fc6f1abff
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the libdvdnav-devel mailing list