[DVDnav-discuss] [PATCH] Set all freed pointers to NULL; for ifofiles, set pointers to NULL instead of zero
Steve Dibb
beandog at gentoo.org
Sat Jan 3 19:00:30 CET 2015
---
src/ifo_read.c | 197
+++++++++++++++++++++++++++++++++++++++++++-------------- 1 file
changed, 148 insertions(+), 49 deletions(-)
diff --git a/src/ifo_read.c b/src/ifo_read.c
index 807ebac..bc26c4d 100644
--- a/src/ifo_read.c
+++ b/src/ifo_read.c
@@ -374,6 +374,7 @@ ifoOpen_try_bup:
if (!ifofile->file) {
fprintf(stderr, "libdvdread: Can't open file %s.\n", ifo_filename);
free(ifofile);
+ ifofile = NULL;
return NULL;
}
bup_file_opened = 1;
@@ -437,6 +438,7 @@ ifo_handle_t *ifoOpenVMGI(dvd_reader_t *dvd) {
if(!ifofile->file) {
fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.IFO.\n");
free(ifofile);
+ ifofile = NULL;
return NULL;
}
@@ -461,6 +463,7 @@ ifo_handle_t *ifoOpenVTSI(dvd_reader_t *dvd, int
title) { if(title <= 0 || title > 99) {
fprintf(stderr, "libdvdread: ifoOpenVTSI invalid title (%d).\n",
title); free(ifofile);
+ ifofile = NULL;
return NULL;
}
@@ -470,6 +473,7 @@ ifo_handle_t *ifoOpenVTSI(dvd_reader_t *dvd, int
title) { if(!ifofile->file) {
fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.IFO.\n",
title); free(ifofile);
+ ifofile = NULL;
return NULL;
}
@@ -501,16 +505,20 @@ void ifoClose(ifo_handle_t *ifofile) {
ifoFree_VTS_PTT_SRPT(ifofile);
ifoFree_VTS_TMAPT(ifofile);
- if(ifofile->vmgi_mat)
+ if(ifofile->vmgi_mat) {
free(ifofile->vmgi_mat);
+ ifofile->vmgi_mat = NULL;
+ }
- if(ifofile->vtsi_mat)
+ if(ifofile->vtsi_mat) {
free(ifofile->vtsi_mat);
+ ifofile->vtsi_mat = NULL;
+ }
DVDCloseFile(ifofile->file);
ifofile->file = 0;
free(ifofile);
- ifofile = 0;
+ ifofile = NULL;
}
@@ -525,19 +533,19 @@ static int ifoRead_VMG(ifo_handle_t *ifofile) {
if(!DVDFileSeek_(ifofile->file, 0)) {
free(ifofile->vmgi_mat);
- ifofile->vmgi_mat = 0;
+ ifofile->vmgi_mat = NULL;
return 0;
}
if(!DVDReadBytes(ifofile->file, vmgi_mat, sizeof(vmgi_mat_t))) {
free(ifofile->vmgi_mat);
- ifofile->vmgi_mat = 0;
+ ifofile->vmgi_mat = NULL;
return 0;
}
if(strncmp("DVDVIDEO-VMG", vmgi_mat->vmg_identifier, 12) != 0) {
free(ifofile->vmgi_mat);
- ifofile->vmgi_mat = 0;
+ ifofile->vmgi_mat = NULL;
return 0;
}
@@ -748,6 +756,7 @@ static int ifoRead_PGC_COMMAND_TBL(ifo_handle_t
*ifofile,
if(!(DVDReadBytes(ifofile->file, cmd_tbl->pre_cmds,
pre_cmds_size))) { free(cmd_tbl->pre_cmds);
+ cmd_tbl->pre_cmds = NULL;
return 0;
}
}
@@ -756,14 +765,19 @@ static int ifoRead_PGC_COMMAND_TBL(ifo_handle_t
*ifofile, unsigned int post_cmds_size = cmd_tbl->nr_of_post *
COMMAND_DATA_SIZE; cmd_tbl->post_cmds = malloc(post_cmds_size);
if(!cmd_tbl->post_cmds) {
- if(cmd_tbl->pre_cmds)
+ if(cmd_tbl->pre_cmds) {
free(cmd_tbl->pre_cmds);
+ cmd_tbl->pre_cmds = NULL;
+ }
return 0;
}
if(!(DVDReadBytes(ifofile->file, cmd_tbl->post_cmds,
post_cmds_size))) {
- if(cmd_tbl->pre_cmds)
+ if(cmd_tbl->pre_cmds) {
free(cmd_tbl->pre_cmds);
+ cmd_tbl->pre_cmds = NULL;
+ }
free(cmd_tbl->post_cmds);
+ cmd_tbl->post_cmds = NULL;
return 0;
}
}
@@ -772,18 +786,27 @@ static int ifoRead_PGC_COMMAND_TBL(ifo_handle_t
*ifofile, unsigned int cell_cmds_size = cmd_tbl->nr_of_cell *
COMMAND_DATA_SIZE; cmd_tbl->cell_cmds = malloc(cell_cmds_size);
if(!cmd_tbl->cell_cmds) {
- if(cmd_tbl->pre_cmds)
+ if(cmd_tbl->pre_cmds) {
free(cmd_tbl->pre_cmds);
- if(cmd_tbl->post_cmds)
+ cmd_tbl->pre_cmds = NULL;
+ }
+ if(cmd_tbl->post_cmds) {
free(cmd_tbl->post_cmds);
+ cmd_tbl->post_cmds = NULL;
+ }
return 0;
}
if(!(DVDReadBytes(ifofile->file, cmd_tbl->cell_cmds,
cell_cmds_size))) {
- if(cmd_tbl->pre_cmds)
+ if(cmd_tbl->pre_cmds) {
free(cmd_tbl->pre_cmds);
- if(cmd_tbl->post_cmds)
+ cmd_tbl->pre_cmds = NULL;
+ }
+ if(cmd_tbl->post_cmds) {
free(cmd_tbl->post_cmds);
+ cmd_tbl->post_cmds = NULL;
+ }
free(cmd_tbl->cell_cmds);
+ cmd_tbl->cell_cmds = NULL;
return 0;
}
}
@@ -797,13 +820,14 @@ static int ifoRead_PGC_COMMAND_TBL(ifo_handle_t
*ifofile,
static void ifoFree_PGC_COMMAND_TBL(pgc_command_tbl_t *cmd_tbl) {
if(cmd_tbl) {
- if(cmd_tbl->nr_of_pre && cmd_tbl->pre_cmds)
- free(cmd_tbl->pre_cmds);
- if(cmd_tbl->nr_of_post && cmd_tbl->post_cmds)
- free(cmd_tbl->post_cmds);
- if(cmd_tbl->nr_of_cell && cmd_tbl->cell_cmds)
- free(cmd_tbl->cell_cmds);
+ free(cmd_tbl->pre_cmds);
+ cmd_tbl->pre_cmds = NULL;
+ free(cmd_tbl->post_cmds);
+ cmd_tbl->post_cmds = NULL;
+ free(cmd_tbl->cell_cmds);
+ cmd_tbl->cell_cmds = NULL;
free(cmd_tbl);
+ cmd_tbl = NULL;
}
}
@@ -922,6 +946,8 @@ static int ifoRead_PGC(ifo_handle_t *ifofile, pgc_t
*pgc, unsigned int offset) {
if(!ifoRead_PGC_COMMAND_TBL(ifofile, pgc->command_tbl,
offset + pgc->command_tbl_offset)) {
+ free(pgc->command_tbl);
+ pgc->command_tbl = NULL;
return 0;
}
} else {
@@ -935,6 +961,8 @@ static int ifoRead_PGC(ifo_handle_t *ifofile, pgc_t
*pgc, unsigned int offset) { }
if(!ifoRead_PGC_PROGRAM_MAP(ifofile,
pgc->program_map,pgc->nr_of_programs, offset +
pgc->program_map_offset)) {
+ free(pgc->program_map);
+ pgc->program_map = NULL;
return 0;
}
} else {
@@ -949,6 +977,8 @@ static int ifoRead_PGC(ifo_handle_t *ifofile, pgc_t
*pgc, unsigned int offset) { if(!ifoRead_CELL_PLAYBACK_TBL(ifofile,
pgc->cell_playback, pgc->nr_of_cells,
offset + pgc->cell_playback_offset))
{
+ free(pgc->cell_playback);
+ pgc->cell_playback = NULL;
return 0;
}
} else {
@@ -963,6 +993,8 @@ static int ifoRead_PGC(ifo_handle_t *ifofile, pgc_t
*pgc, unsigned int offset) { if(!ifoRead_CELL_POSITION_TBL(ifofile,
pgc->cell_position, pgc->nr_of_cells,
offset + pgc->cell_position_offset))
{
+ free(pgc->cell_position);
+ pgc->cell_position = NULL;
return 0;
}
} else {
@@ -1051,6 +1083,8 @@ int ifoRead_TT_SRPT(ifo_handle_t *ifofile) {
if(!(DVDReadBytes(ifofile->file, tt_srpt, TT_SRPT_SIZE))) {
fprintf(stderr, "libdvdread: Unable to read read TT_SRPT.\n");
free(tt_srpt);
+ tt_srpt = NULL;
+ ifofile->tt_srpt = NULL;
return 0;
}
@@ -1062,7 +1096,8 @@ int ifoRead_TT_SRPT(ifo_handle_t *ifofile) {
tt_srpt->title = malloc(info_length);
if(!tt_srpt->title) {
free(tt_srpt);
- ifofile->tt_srpt = 0;
+ tt_srpt = NULL;
+ ifofile->tt_srpt = NULL;
return 0;
}
if(!(DVDReadBytes(ifofile->file, tt_srpt->title, info_length))) {
@@ -1231,8 +1266,10 @@ int ifoRead_VTS_PTT_SRPT(ifo_handle_t *ifofile) {
vts_ptt_srpt->title[i].nr_of_ptts = n / 4;
vts_ptt_srpt->title[i].ptt = malloc(n * sizeof(ptt_info_t));
if(!vts_ptt_srpt->title[i].ptt) {
- for(n = 0; n < i; n++)
+ for(n = 0; n < i; n++) {
free(vts_ptt_srpt->title[n].ptt);
+ vts_ptt_srpt->title[n].ptt = NULL;
+ }
goto fail;
}
@@ -1276,9 +1313,12 @@ int ifoRead_VTS_PTT_SRPT(ifo_handle_t *ifofile) {
fail:
free(data);
- ifofile->vts_ptt_srpt = 0;
+ data = NULL;
+ ifofile->vts_ptt_srpt = NULL;
free(vts_ptt_srpt->title);
+ vts_ptt_srpt->title = NULL;
free(vts_ptt_srpt);
+ vts_ptt_srpt = NULL;
return 0;
}
@@ -1289,12 +1329,16 @@ void ifoFree_VTS_PTT_SRPT(ifo_handle_t
*ifofile) {
if(ifofile->vts_ptt_srpt) {
int i;
- for(i = 0; i < ifofile->vts_ptt_srpt->nr_of_srpts; i++)
+ for(i = 0; i < ifofile->vts_ptt_srpt->nr_of_srpts; i++) {
free(ifofile->vts_ptt_srpt->title[i].ptt);
+ ifofile->vts_ptt_srpt->title[i].ptt = NULL;
+ }
free(ifofile->vts_ptt_srpt->ttu_offset);
+ ifofile->vts_ptt_srpt->ttu_offset = NULL;
free(ifofile->vts_ptt_srpt->title);
+ ifofile->vts_ptt_srpt->title = NULL;
free(ifofile->vts_ptt_srpt);
- ifofile->vts_ptt_srpt = 0;
+ ifofile->vts_ptt_srpt = NULL;
}
}
@@ -1324,6 +1368,7 @@ int ifoRead_PTL_MAIT(ifo_handle_t *ifofile) {
if(!(DVDReadBytes(ifofile->file, ptl_mait, PTL_MAIT_SIZE))) {
free(ptl_mait);
+ ptl_mait = NULL;
ifofile->ptl_mait = NULL;
return 0;
}
@@ -1343,6 +1388,7 @@ int ifoRead_PTL_MAIT(ifo_handle_t *ifofile) {
ptl_mait->countries = malloc(info_length);
if(!ptl_mait->countries) {
free(ptl_mait);
+ ptl_mait = NULL;
ifofile->ptl_mait = NULL;
return 0;
}
@@ -1354,7 +1400,9 @@ int ifoRead_PTL_MAIT(ifo_handle_t *ifofile) {
if(!(DVDReadBytes(ifofile->file, &ptl_mait->countries[i],
PTL_MAIT_COUNTRY_SIZE))) { fprintf(stderr, "libdvdread: Unable to read
PTL_MAIT.\n"); free(ptl_mait->countries);
+ ptl_mait->countries = NULL;
free(ptl_mait);
+ ptl_mait = NULL;
ifofile->ptl_mait = NULL;
return 0;
}
@@ -1380,7 +1428,9 @@ int ifoRead_PTL_MAIT(ifo_handle_t *ifofile) {
+ ptl_mait->countries[i].pf_ptl_mai_start_byte)) {
fprintf(stderr, "libdvdread: Unable to seek PTL_MAIT table at
index %d.\n",i); free(ptl_mait->countries);
+ ptl_mait->countries = NULL;
free(ptl_mait);
+ ptl_mait = NULL;
ifofile->ptl_mait = NULL;
return 0;
}
@@ -1395,6 +1445,7 @@ int ifoRead_PTL_MAIT(ifo_handle_t *ifofile) {
if(!(DVDReadBytes(ifofile->file, pf_temp, info_length))) {
fprintf(stderr, "libdvdread: Unable to read PTL_MAIT table at
index %d.\n",i); free(pf_temp);
+ pf_temp = NULL;
free_ptl_mait(ptl_mait, i);
ifofile->ptl_mait = NULL;
return 0;
@@ -1405,6 +1456,7 @@ int ifoRead_PTL_MAIT(ifo_handle_t *ifofile) {
ptl_mait->countries[i].pf_ptl_mai = malloc(info_length);
if(!ptl_mait->countries[i].pf_ptl_mai) {
free(pf_temp);
+ pf_temp = NULL;
free_ptl_mait(ptl_mait, i);
ifofile->ptl_mait = NULL;
return 0;
@@ -1418,6 +1470,7 @@ int ifoRead_PTL_MAIT(ifo_handle_t *ifofile) {
}
}
free(pf_temp);
+ pf_temp = NULL;
}
}
return 1;
@@ -1432,8 +1485,10 @@ void ifoFree_PTL_MAIT(ifo_handle_t *ifofile) {
for(i = 0; i < ifofile->ptl_mait->nr_of_countries; i++) {
free(ifofile->ptl_mait->countries[i].pf_ptl_mai);
+ ifofile->ptl_mait->countries[i].pf_ptl_mai = NULL;
}
free(ifofile->ptl_mait->countries);
+ ifofile->ptl_mait->countries = NULL;
free(ifofile->ptl_mait);
ifofile->ptl_mait = NULL;
}
@@ -1471,6 +1526,7 @@ int ifoRead_VTS_TMAPT(ifo_handle_t *ifofile) {
if(!(DVDReadBytes(ifofile->file, vts_tmapt, VTS_TMAPT_SIZE))) {
fprintf(stderr, "libdvdread: Unable to read VTS_TMAPT.\n");
free(vts_tmapt);
+ vts_tmapt = NULL;
ifofile->vts_tmapt = NULL;
return 0;
}
@@ -1485,6 +1541,7 @@ int ifoRead_VTS_TMAPT(ifo_handle_t *ifofile) {
vts_tmap_srp = malloc(info_length);
if(!vts_tmap_srp) {
free(vts_tmapt);
+ vts_tmapt = NULL;
ifofile->vts_tmapt = NULL;
return 0;
}
@@ -1494,7 +1551,9 @@ int ifoRead_VTS_TMAPT(ifo_handle_t *ifofile) {
if(!(DVDReadBytes(ifofile->file, vts_tmap_srp, info_length))) {
fprintf(stderr, "libdvdread: Unable to read VTS_TMAPT.\n");
free(vts_tmap_srp);
+ vts_tmap_srp = NULL;
free(vts_tmapt);
+ vts_tmapt = NULL;
ifofile->vts_tmapt = NULL;
return 0;
}
@@ -1509,7 +1568,9 @@ int ifoRead_VTS_TMAPT(ifo_handle_t *ifofile) {
vts_tmapt->tmap = malloc(info_length);
if(!vts_tmapt->tmap) {
free(vts_tmap_srp);
+ vts_tmap_srp = NULL;
free(vts_tmapt);
+ vts_tmapt = NULL;
ifofile->vts_tmapt = NULL;
return 0;
}
@@ -1565,10 +1626,14 @@ void ifoFree_VTS_TMAPT(ifo_handle_t *ifofile) {
unsigned int i;
for(i = 0; i < ifofile->vts_tmapt->nr_of_tmaps; i++)
- if(ifofile->vts_tmapt->tmap[i].map_ent)
+ if(ifofile->vts_tmapt->tmap[i].map_ent) {
free(ifofile->vts_tmapt->tmap[i].map_ent);
+ ifofile->vts_tmapt->tmap[i].map_ent = NULL;
+ }
free(ifofile->vts_tmapt->tmap);
+ ifofile->vts_tmapt->tmap = NULL;
free(ifofile->vts_tmapt->tmap_offset);
+ ifofile->vts_tmapt->tmap_offset = NULL;
free(ifofile->vts_tmapt);
ifofile->vts_tmapt = NULL;
}
@@ -1593,7 +1658,7 @@ int ifoRead_TITLE_C_ADT(ifo_handle_t *ifofile) {
if(!ifoRead_C_ADT_internal(ifofile, ifofile->vts_c_adt,
ifofile->vtsi_mat->vts_c_adt)) {
free(ifofile->vts_c_adt);
- ifofile->vts_c_adt = 0;
+ ifofile->vts_c_adt = NULL;
return 0;
}
@@ -1624,7 +1689,7 @@ int ifoRead_C_ADT(ifo_handle_t *ifofile) {
if(!ifoRead_C_ADT_internal(ifofile, ifofile->menu_c_adt, sector)) {
free(ifofile->menu_c_adt);
- ifofile->menu_c_adt = 0;
+ ifofile->menu_c_adt = NULL;
return 0;
}
@@ -1670,6 +1735,7 @@ static int ifoRead_C_ADT_internal(ifo_handle_t
*ifofile, if(info_length &&
!(DVDReadBytes(ifofile->file, c_adt->cell_adr_table,
info_length))) { free(c_adt->cell_adr_table);
+ c_adt->cell_adr_table = NULL;
return 0;
}
@@ -1693,7 +1759,9 @@ static int ifoRead_C_ADT_internal(ifo_handle_t
*ifofile, static void ifoFree_C_ADT_internal(c_adt_t *c_adt) {
if(c_adt) {
free(c_adt->cell_adr_table);
+ c_adt->cell_adr_table = NULL;
free(c_adt);
+ c_adt = NULL;
}
}
@@ -1702,7 +1770,7 @@ void ifoFree_C_ADT(ifo_handle_t *ifofile) {
return;
ifoFree_C_ADT_internal(ifofile->menu_c_adt);
- ifofile->menu_c_adt = 0;
+ ifofile->menu_c_adt = NULL;
}
void ifoFree_TITLE_C_ADT(ifo_handle_t *ifofile) {
@@ -1710,7 +1778,7 @@ void ifoFree_TITLE_C_ADT(ifo_handle_t *ifofile) {
return;
ifoFree_C_ADT_internal(ifofile->vts_c_adt);
- ifofile->vts_c_adt = 0;
+ ifofile->vts_c_adt = NULL;
}
int ifoRead_TITLE_VOBU_ADMAP(ifo_handle_t *ifofile) {
@@ -1730,7 +1798,7 @@ int ifoRead_TITLE_VOBU_ADMAP(ifo_handle_t
*ifofile) { if(!ifoRead_VOBU_ADMAP_internal(ifofile,
ifofile->vts_vobu_admap, ifofile->vtsi_mat->vts_vobu_admap)) {
free(ifofile->vts_vobu_admap);
- ifofile->vts_vobu_admap = 0;
+ ifofile->vts_vobu_admap = NULL;
return 0;
}
@@ -1761,7 +1829,7 @@ int ifoRead_VOBU_ADMAP(ifo_handle_t *ifofile) {
if(!ifoRead_VOBU_ADMAP_internal(ifofile, ifofile->menu_vobu_admap,
sector)) { free(ifofile->menu_vobu_admap);
- ifofile->menu_vobu_admap = 0;
+ ifofile->menu_vobu_admap = NULL;
return 0;
}
@@ -1796,6 +1864,7 @@ static int
ifoRead_VOBU_ADMAP_internal(ifo_handle_t
*ifofile, !(DVDReadBytes(ifofile->file, vobu_admap->vobu_start_sectors,
info_length))) { free(vobu_admap->vobu_start_sectors);
+ vobu_admap->vobu_start_sectors = NULL;
return 0;
}
@@ -1809,7 +1878,9 @@ static int
ifoRead_VOBU_ADMAP_internal(ifo_handle_t *ifofile, static void
ifoFree_VOBU_ADMAP_internal(vobu_admap_t *vobu_admap) { if(vobu_admap) {
free(vobu_admap->vobu_start_sectors);
+ vobu_admap->vobu_start_sectors = NULL;
free(vobu_admap);
+ vobu_admap = NULL;
}
}
@@ -1818,7 +1889,7 @@ void ifoFree_VOBU_ADMAP(ifo_handle_t *ifofile) {
return;
ifoFree_VOBU_ADMAP_internal(ifofile->menu_vobu_admap);
- ifofile->menu_vobu_admap = 0;
+ ifofile->menu_vobu_admap = NULL;
}
void ifoFree_TITLE_VOBU_ADMAP(ifo_handle_t *ifofile) {
@@ -1826,7 +1897,7 @@ void ifoFree_TITLE_VOBU_ADMAP(ifo_handle_t
*ifofile) { return;
ifoFree_VOBU_ADMAP_internal(ifofile->vts_vobu_admap);
- ifofile->vts_vobu_admap = 0;
+ ifofile->vts_vobu_admap = NULL;
}
int ifoRead_PGCIT(ifo_handle_t *ifofile) {
@@ -1848,7 +1919,7 @@ int ifoRead_PGCIT(ifo_handle_t *ifofile) {
if(!ifoRead_PGCIT_internal(ifofile, ifofile->vts_pgcit,
ifofile->vtsi_mat->vts_pgcit *
DVD_BLOCK_LEN)) { free(ifofile->vts_pgcit);
- ifofile->vts_pgcit = 0;
+ ifofile->vts_pgcit = NULL;
return 0;
}
@@ -1893,12 +1964,14 @@ static int ifoRead_PGCIT_internal(ifo_handle_t
*ifofile, pgcit_t *pgcit,
if(info_length && !(DVDReadBytes(ifofile->file, data, info_length)))
{ free(data);
+ data = NULL;
return 0;
}
pgcit->pgci_srp = malloc(pgcit->nr_of_pgci_srp * sizeof(pgci_srp_t));
if(!pgcit->pgci_srp) {
free(data);
+ data = NULL;
return 0;
}
ptr = data;
@@ -1909,6 +1982,7 @@ static int ifoRead_PGCIT_internal(ifo_handle_t
*ifofile, pgcit_t *pgcit, CHECK_VALUE(pgcit->pgci_srp[i].unknown1 == 0);
}
free(data);
+ data = NULL;
for(i = 0; i < pgcit->nr_of_pgci_srp; i++)
CHECK_VALUE(pgcit->pgci_srp[i].pgc_start_byte + PGC_SIZE <=
pgcit->last_byte+1); @@ -1936,6 +2010,7 @@ static int
ifoRead_PGCIT_internal(ifo_handle_t *ifofile, pgcit_t *pgcit,
ifoFree_PGC(&pgcit->pgci_srp[j].pgc); }
free(pgcit->pgci_srp[i].pgc);
+ pgcit->pgci_srp[i].pgc = NULL;
goto fail;
}
}
@@ -1955,7 +2030,9 @@ static void ifoFree_PGCIT_internal(pgcit_t
**pgcit) { ifoFree_PGC(&(*pgcit)->pgci_srp[i].pgc);
}
free((*pgcit)->pgci_srp);
+ (*pgcit)->pgci_srp = NULL;
free(*pgcit);
+ *pgcit = NULL;
}
if (pgcit)
*pgcit = NULL;
@@ -2009,13 +2086,13 @@ int ifoRead_PGCI_UT(ifo_handle_t *ifofile) {
if(!DVDFileSeek_(ifofile->file, sector * DVD_BLOCK_LEN)) {
free(ifofile->pgci_ut);
- ifofile->pgci_ut = 0;
+ ifofile->pgci_ut = NULL;
return 0;
}
if(!(DVDReadBytes(ifofile->file, ifofile->pgci_ut, PGCI_UT_SIZE))) {
free(ifofile->pgci_ut);
- ifofile->pgci_ut = 0;
+ ifofile->pgci_ut = NULL;
return 0;
}
@@ -2033,21 +2110,26 @@ int ifoRead_PGCI_UT(ifo_handle_t *ifofile) {
data = malloc(info_length);
if(!data) {
free(pgci_ut);
- ifofile->pgci_ut = 0;
+ pgci_ut = NULL;
+ ifofile->pgci_ut = NULL;
return 0;
}
if(!(DVDReadBytes(ifofile->file, data, info_length))) {
free(data);
+ data = NULL;
free(pgci_ut);
- ifofile->pgci_ut = 0;
+ pgci_ut = NULL;
+ ifofile->pgci_ut = NULL;
return 0;
}
pgci_ut->lu = malloc(pgci_ut->nr_of_lus * sizeof(pgci_lu_t));
if(!pgci_ut->lu) {
free(data);
+ data = NULL;
free(pgci_ut);
- ifofile->pgci_ut = 0;
+ pgci_ut = NULL;
+ ifofile->pgci_ut = NULL;
return 0;
}
ptr = data;
@@ -2058,6 +2140,7 @@ int ifoRead_PGCI_UT(ifo_handle_t *ifofile) {
B2N_32(pgci_ut->lu[i].lang_start_byte);
}
free(data);
+ data = NULL;
for(i = 0; i < pgci_ut->nr_of_lus; i++) {
/* Maybe this is only defined for v1.1 and later titles? */
@@ -2086,8 +2169,10 @@ int ifoRead_PGCI_UT(ifo_handle_t *ifofile) {
ifoFree_PGCIT_internal(&pgci_ut->lu[j].pgcit);
}
free(pgci_ut->lu);
+ pgci_ut->lu = NULL;
free(pgci_ut);
- ifofile->pgci_ut = 0;
+ pgci_ut = NULL;
+ ifofile->pgci_ut = NULL;
return 0;
}
pgci_ut->lu[i].pgcit->ref_count = 1;
@@ -2099,8 +2184,10 @@ int ifoRead_PGCI_UT(ifo_handle_t *ifofile) {
ifoFree_PGCIT_internal(&pgci_ut->lu[j].pgcit);
}
free(pgci_ut->lu);
+ pgci_ut->lu = NULL;
free(pgci_ut);
- ifofile->pgci_ut = 0;
+ pgci_ut = NULL;
+ ifofile->pgci_ut = NULL;
return 0;
}
/* FIXME: Iterate and verify that all menus that should exists
accordingly @@ -2122,8 +2209,9 @@ void ifoFree_PGCI_UT(ifo_handle_t
*ifofile) { ifoFree_PGCIT_internal(&ifofile->pgci_ut->lu[i].pgcit);
}
free(ifofile->pgci_ut->lu);
+ ifofile->pgci_ut->lu = NULL;
free(ifofile->pgci_ut);
- ifofile->pgci_ut = 0;
+ ifofile->pgci_ut = NULL;
}
}
@@ -2206,7 +2294,8 @@ int ifoRead_VTS_ATRT(ifo_handle_t *ifofile) {
if(!(DVDReadBytes(ifofile->file, vts_atrt, VTS_ATRT_SIZE))) {
free(vts_atrt);
- ifofile->vts_atrt = 0;
+ vts_atrt = NULL;
+ ifofile->vts_atrt = NULL;
return 0;
}
@@ -2223,7 +2312,8 @@ int ifoRead_VTS_ATRT(ifo_handle_t *ifofile) {
data = malloc(info_length);
if(!data) {
free(vts_atrt);
- ifofile->vts_atrt = 0;
+ vts_atrt = NULL;
+ ifofile->vts_atrt = NULL;
return 0;
}
@@ -2231,8 +2321,10 @@ int ifoRead_VTS_ATRT(ifo_handle_t *ifofile) {
if(!(DVDReadBytes(ifofile->file, data, info_length))) {
free(data);
+ data = NULL;
free(vts_atrt);
- ifofile->vts_atrt = 0;
+ vts_atrt = NULL;
+ ifofile->vts_atrt = NULL;
return 0;
}
@@ -2245,8 +2337,10 @@ int ifoRead_VTS_ATRT(ifo_handle_t *ifofile) {
vts_atrt->vts = malloc(info_length);
if(!vts_atrt->vts) {
free(data);
+ data = NULL;
free(vts_atrt);
- ifofile->vts_atrt = 0;
+ vts_atrt = NULL;
+ ifofile->vts_atrt = NULL;
return 0;
}
for(i = 0; i < vts_atrt->nr_of_vtss; i++) {
@@ -2254,8 +2348,10 @@ int ifoRead_VTS_ATRT(ifo_handle_t *ifofile) {
if(!ifoRead_VTS_ATTRIBUTES(ifofile, &(vts_atrt->vts[i]),
(sector * DVD_BLOCK_LEN) + offset)) {
free(data);
+ data = NULL;
free(vts_atrt);
- ifofile->vts_atrt = 0;
+ vts_atrt = NULL;
+ ifofile->vts_atrt = NULL;
return 0;
}
@@ -2274,9 +2370,11 @@ void ifoFree_VTS_ATRT(ifo_handle_t *ifofile) {
if(ifofile->vts_atrt) {
free(ifofile->vts_atrt->vts);
+ ifofile->vts_atrt->vts = NULL;
free(ifofile->vts_atrt->vts_atrt_offsets);
+ ifofile->vts_atrt->vts_atrt_offsets = NULL;
free(ifofile->vts_atrt);
- ifofile->vts_atrt = 0;
+ ifofile->vts_atrt = NULL;
}
}
@@ -2307,7 +2405,8 @@ int ifoRead_TXTDT_MGI(ifo_handle_t *ifofile) {
if(!(DVDReadBytes(ifofile->file, txtdt_mgi, TXTDT_MGI_SIZE))) {
fprintf(stderr, "libdvdread: Unable to read TXTDT_MGI.\n");
free(txtdt_mgi);
- ifofile->txtdt_mgi = 0;
+ txtdt_mgi = NULL;
+ ifofile->txtdt_mgi = NULL;
return 0;
}
@@ -2321,6 +2420,6 @@ void ifoFree_TXTDT_MGI(ifo_handle_t *ifofile) {
if(ifofile->txtdt_mgi) {
free(ifofile->txtdt_mgi);
- ifofile->txtdt_mgi = 0;
+ ifofile->txtdt_mgi = NULL;
}
}
--
2.0.4
More information about the DVDnav-discuss
mailing list