[libdvdnav-devel] [Git][videolan/libdvdread][master] ifo_read: fix leaks on ifoRead_TT error paths
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Tue Dec 1 13:52:24 UTC 2026
Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdread
Commits:
59d9ef27 by Jean-Baptiste Kempf at 2026-10-08T18:36:10+00:00
ifo_read: fix leaks on ifoRead_TT error paths
The fail_audio label only freed the arrays of previous loop iterations,
so a mid-iteration failure leaked the current title's buffers: a failed
atsi_track_pointer_rows allocation leaked atsi_track_timestamp_rows, and
a failed timestamp read freed timestamp_rows but leaked pointer_rows,
leaving dangling pointers in the table.
Free the current entry in fail_audio instead of at each failure site;
the row table is calloc'd and the pointer members sit after the 16 raw
header bytes, so unallocated members are NULL.
Co-Authored-By: Claude Fable 5 <noreply at anthropic.com>
- - - - -
1 changed file:
- src/ifo_read.c
Changes:
=====================================
src/ifo_read.c
=====================================
@@ -1274,21 +1274,16 @@ int ifoRead_TT(ifo_handle_t *ifofile) {
if(!DVDReadBytes(ifop->file, index->atsi_track_timestamp_rows,
nr_tracks * sizeof(atsi_track_timestamp_t))) {
- free(index->atsi_track_timestamp_rows);
goto fail_audio;
}
if(!DVDFileSeek_(ifop->file, (atsi_title_table->atsi_index_rows + i)->offset_record_table
+ index->start_sector_pointers_table + DVD_BLOCK_LEN)) {
- free(index->atsi_track_timestamp_rows);
- free(index->atsi_track_pointer_rows);
goto fail_audio;
}
if(!DVDReadBytes(ifop->file, index->atsi_track_pointer_rows,
nr_pointer_records * sizeof(atsi_track_pointer_t))) {
- free(index->atsi_track_timestamp_rows);
- free(index->atsi_track_pointer_rows);
goto fail_audio;
}
@@ -1316,7 +1311,9 @@ int ifoRead_TT(ifo_handle_t *ifofile) {
return 1;
fail_audio:
- for (int j = 0; j < i; j++){
+ /* also free the partially loaded entry i; unallocated members of the
+ * calloc'd table are NULL */
+ for (int j = 0; j <= i; j++){
free((atsi_title_table->atsi_title_row_tables + j)->atsi_track_pointer_rows);
free((atsi_title_table->atsi_title_row_tables + j)->atsi_track_timestamp_rows);
free((atsi_title_table->atsi_title_row_tables + j)->ats_pg_asv_pbi_srp);
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/commit/59d9ef27e1df689cf19ee25ea1b14ee2ffd4887e
--
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/commit/59d9ef27e1df689cf19ee25ea1b14ee2ffd4887e
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