Commit d510f69b authored by François Cartegnie's avatar François Cartegnie 🤞

access: dvb: scan: fix scan parameter alloc/free/const violation

parent 123d0b1c
......@@ -157,17 +157,21 @@ static int Open( vlc_object_t *p_this )
scan_parameter_t parameter;
scan_t *p_scan;
scan_parameter_Init( &parameter );
msg_Dbg( p_access, "setting filter on PAT/NIT/SDT (DVB only)" );
FilterSet( p_access, 0x00, OTHER_TYPE ); // PAT
FilterSet( p_access, 0x10, OTHER_TYPE ); // NIT
FilterSet( p_access, 0x11, OTHER_TYPE ); // SDT
if( FrontendGetScanParameter( p_access, &parameter ) ||
if( FrontendFillScanParameter( p_access, &parameter ) ||
(p_scan = scan_New( VLC_OBJECT(p_access), &parameter )) == NULL )
{
scan_parameter_Clean( &parameter );
Close( VLC_OBJECT(p_access) );
return VLC_EGENERIC;
}
scan_parameter_Clean( &parameter );
p_sys->scan = p_scan;
p_sys->i_read_once = DVB_READ_ONCE_SCAN;
}
......
......@@ -91,7 +91,7 @@ void FrontendClose( access_t * );
int FrontendGetStatistic( access_t *, frontend_statistic_t * );
void FrontendGetStatus( access_t *, frontend_status_t * );
int FrontendGetScanParameter( access_t *, struct scan_parameter_t * );
int FrontendFillScanParameter( access_t *, struct scan_parameter_t * );
int DMXSetFilter( access_t *, int i_pid, int * pi_fd, int i_type );
int DMXUnsetFilter( access_t *, int i_fd );
......
......@@ -383,7 +383,6 @@ static int ScanParametersDvbS( access_t *p_access, scan_parameter_t *p_scan )
{
const frontend_t *p_frontend = p_access->p_sys->p_frontend;
memset( p_scan, 0, sizeof(*p_scan) );
p_scan->type = SCAN_DVB_S;
p_scan->frequency.i_min = p_frontend->info.frequency_min;
......@@ -398,7 +397,6 @@ static int ScanParametersDvbC( access_t *p_access, scan_parameter_t *p_scan )
{
const frontend_t *p_frontend = p_access->p_sys->p_frontend;
memset( p_scan, 0, sizeof(*p_scan) );
p_scan->type = SCAN_DVB_C;
p_scan->b_exhaustive = false;
......@@ -437,7 +435,6 @@ static int ScanParametersDvbT( access_t *p_access, scan_parameter_t *p_scan )
{
const frontend_t *p_frontend = p_access->p_sys->p_frontend;
memset( p_scan, 0, sizeof(*p_scan) );
p_scan->type = SCAN_DVB_T;
p_scan->b_exhaustive = false;
......@@ -456,7 +453,7 @@ static int ScanParametersDvbT( access_t *p_access, scan_parameter_t *p_scan )
return VLC_SUCCESS;
}
int FrontendGetScanParameter( access_t *p_access, scan_parameter_t *p_scan )
int FrontendFillScanParameter( access_t *p_access, scan_parameter_t *p_scan )
{
access_sys_t *p_sys = p_access->p_sys;
const frontend_t *p_frontend = p_sys->p_frontend;
......
......@@ -184,6 +184,25 @@ static int scan_service_type( int service_type )
}
}
void scan_parameter_Init( scan_parameter_t *p_dst )
{
memset( p_dst, 0, sizeof(*p_dst) );
}
void scan_parameter_Clean( scan_parameter_t *p_dst )
{
if( p_dst->sat_info.psz_name )
free( p_dst->sat_info.psz_name );
}
static void scan_parameter_Copy( const scan_parameter_t *p_src, scan_parameter_t *p_dst )
{
scan_parameter_Clean( p_dst );
*p_dst = *p_src;
if( p_src->sat_info.psz_name )
p_dst->sat_info.psz_name = strdup( p_src->sat_info.psz_name );
}
/* */
scan_t *scan_New( vlc_object_t *p_obj, const scan_parameter_t *p_parameter )
{
......@@ -226,7 +245,8 @@ scan_t *scan_New( vlc_object_t *p_obj, const scan_parameter_t *p_parameter )
p_scan->i_index = 0;
p_scan->p_dialog_id = NULL;
TAB_INIT( p_scan->i_service, p_scan->pp_service );
p_scan->parameter = *p_parameter;
scan_parameter_Init( &p_scan->parameter );
scan_parameter_Copy( p_parameter, &p_scan->parameter );
p_scan->i_time_start = mdate();
return p_scan;
......@@ -239,6 +259,8 @@ void scan_Destroy( scan_t *p_scan )
if( p_scan->p_dialog_id != NULL )
vlc_dialog_release( p_scan->p_obj, p_scan->p_dialog_id );
scan_parameter_Clean( &p_scan->parameter );
for( int i = 0; i < p_scan->i_service; i++ )
scan_service_Delete( p_scan->pp_service[i] );
TAB_CLEAN( p_scan->i_service, p_scan->pp_service );
......@@ -266,7 +288,6 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
p_scan->parameter.sat_info.psz_name ) == -1 )
{
free( data_dir );
free( p_scan->parameter.sat_info.psz_name );
return VLC_EGENERIC;
}
free( data_dir );
......@@ -277,7 +298,6 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
if( !f )
{
msg_Err( p_scan->p_obj, "failed to open satellite file (%s)", psz_path );
free( p_scan->parameter.sat_info.psz_name );
free( psz_path );
return VLC_EGENERIC;
}
......@@ -329,7 +349,6 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
p_scan->p_transponders = p_transponders;
fclose( f );
free( p_scan->parameter.sat_info.psz_name );
}
if( p_scan->i_index < p_scan->i_transponders )
......
......@@ -82,6 +82,9 @@ typedef struct
typedef struct scan_t scan_t;
void scan_parameter_Init( scan_parameter_t * );
void scan_parameter_Clean( scan_parameter_t * );
scan_t *scan_New( vlc_object_t *p_obj, const scan_parameter_t *p_parameter );
void scan_Destroy( scan_t *p_scan );
......
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