Commit ba2dbc41 authored by Johan Bilien's avatar Johan Bilien

fixed a segfault in vcd input (thank you Sam)

parent 2d90188b
......@@ -319,8 +319,8 @@ static void VCDInit( input_thread_t * p_input )
area[i]->i_id = i;
/* Absolute start offset and size */
area[i]->i_start = p_vcd->tracks_sector[i+1];
area[i]->i_size = p_vcd->tracks_sector[i+2] - p_vcd->tracks_sector[i+1];
area[i]->i_start = p_vcd->tracks_sector[i];
area[i]->i_size = p_vcd->tracks_sector[i+1] - p_vcd->tracks_sector[i];
/* Number of chapters */
area[i]->i_part_nb = 0; // will be the entry points
......@@ -330,7 +330,7 @@ static void VCDInit( input_thread_t * p_input )
area[i]->i_angle_nb = 1; // no angle support in VCDs
area[i]->i_angle = 1;
area[i]->i_plugin_data = p_vcd->tracks_sector[i+1];
area[i]->i_plugin_data = p_vcd->tracks_sector[i];
}
#undef area
......@@ -338,7 +338,7 @@ static void VCDInit( input_thread_t * p_input )
i_title = main_GetIntVariable( INPUT_TITLE_VAR, 1 );
if( i_title <= 0)
{
i_title = 2;
i_title = 1;
}
// p_vcd->current_track = i_title-1 ;
......@@ -434,14 +434,14 @@ static int VCDSetArea( input_thread_t * p_input, input_area_t * p_area )
{
/* Reset the Chapter position of the old title */
p_input->stream.p_selected_area->i_part = 0;
p_input->stream.p_selected_area->i_tell = 0;
/* Change the default area */
p_input->stream.p_selected_area =
p_input->stream.pp_areas[p_area->i_id];
p_input->stream.p_selected_area = p_area;
/* Change the current track */
/* The first track is not a valid one */
p_vcd->current_track = p_area->i_id + 1 ;
p_vcd->current_track = p_area->i_id ;
p_vcd->current_sector = p_vcd->tracks_sector[p_vcd->current_track] ;
}
/* warn interface that something has changed */
......@@ -616,9 +616,6 @@ static int VCDRead( input_thread_t * p_input,
}
vlc_mutex_lock( &p_input->stream.stream_lock );
......@@ -635,8 +632,8 @@ static int VCDRead( input_thread_t * p_input,
}*/
b_eof = p_vcd->b_end_of_track &&
( ( p_vcd->current_track + 1 ) >= p_vcd->nb_tracks );
b_eof = p_vcd->b_end_of_track;
/*FIXME&& ( ( p_vcd->current_track ) >= p_vcd->nb_tracks - 1);*/
if( b_eof )
{
......@@ -647,9 +644,9 @@ static int VCDRead( input_thread_t * p_input,
if( p_vcd->b_end_of_track )
{
intf_WarnMsg( 4, "vcd info: new title" );
p_vcd->current_track++;
p_vcd->b_end_of_track = 0;
VCDSetArea( p_input, p_input->stream.pp_areas[p_vcd->current_track] );
VCDSetArea( p_input, p_input->stream.pp_areas[
p_input->stream.p_selected_area->i_id + 1] );
vlc_mutex_unlock( &p_input->stream.stream_lock );
return 0;
}
......
......@@ -95,7 +95,7 @@ int read_toc ( thread_vcd_data_t * p_vcd )
p_vcd->nb_tracks = tochdr.cdth_trk1;
/* nb_tracks + 1 because we put the lead_out tracks for computing last
track's size */
p_vcd->tracks_sector = malloc( (p_vcd->nb_tracks + 1)
p_vcd->tracks_sector = malloc( ( p_vcd->nb_tracks + 1 )
* sizeof( int ) );
if ( p_vcd->tracks_sector == NULL )
{
......@@ -105,18 +105,18 @@ int read_toc ( thread_vcd_data_t * p_vcd )
/* then for each track we read its TOC entry */
for(i=tochdr.cdth_trk0 ;i<=tochdr.cdth_trk1;i++)
for( i=tochdr.cdth_trk0 ; i <= tochdr.cdth_trk1 ; i++ )
{
tocent.cdte_track = i ;
tocent.cdte_format = CDROM_LBA ;
if (ioctl(fd, CDROMREADTOCENTRY, &tocent) == -1)
tocent.cdte_track = i;
tocent.cdte_format = CDROM_LBA;
if (ioctl( fd, CDROMREADTOCENTRY, &tocent) == -1 )
{
intf_ErrMsg("problem occured when reading CD's TOCENTRY\n") ;
free (p_vcd->tracks_sector) ;
return -1 ;
intf_ErrMsg( "problem occured when reading CD's TOCENTRY\n" );
free ( p_vcd->tracks_sector );
return -1;
}
p_vcd->tracks_sector[i] = tocent.cdte_addr.lba ;
p_vcd->tracks_sector[i-1] = tocent.cdte_addr.lba ;
}
......@@ -132,7 +132,7 @@ int read_toc ( thread_vcd_data_t * p_vcd )
return -1 ;
}
p_vcd->tracks_sector[p_vcd->nb_tracks + 1] = tocent.cdte_addr.lba ;
p_vcd->tracks_sector[p_vcd->nb_tracks] = tocent.cdte_addr.lba ;
return 1 ;
......
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