[vlc-commits] access: dvb: scan: early fail/release psz_path
Francois Cartegnie
git at videolan.org
Sun Apr 10 13:56:10 CEST 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Apr 6 14:48:08 2016 +0200| [123d0b1c39dc4666ec90e3549326129056172295] | committer: Francois Cartegnie
access: dvb: scan: early fail/release psz_path
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=123d0b1c39dc4666ec90e3549326129056172295
---
modules/access/dvb/scan.c | 92 ++++++++++++++++++++++-----------------------
1 file changed, 44 insertions(+), 48 deletions(-)
diff --git a/modules/access/dvb/scan.c b/modules/access/dvb/scan.c
index 5a1ca1e..20a6634 100644
--- a/modules/access/dvb/scan.c
+++ b/modules/access/dvb/scan.c
@@ -274,66 +274,62 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
msg_Dbg( p_scan->p_obj, "using satellite config file (%s)", psz_path );
FILE *f = vlc_fopen( psz_path, "r" );
+ 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;
+ }
+ free( psz_path );
/* parse file */
- if( f )
+ scan_dvbs_transponder_t *p_transponders = malloc( sizeof( scan_dvbs_transponder_t ) );
+ if( !p_transponders )
{
- scan_dvbs_transponder_t *p_transponders = malloc( sizeof( scan_dvbs_transponder_t ) );
- if( !p_transponders )
- {
- fclose( f );
- free( psz_path );
- return VLC_ENOMEM;
- }
+ fclose( f );
+ return VLC_ENOMEM;
+ }
- char type;
- char psz_fec[3];
+ char type;
+ char psz_fec[3];
- int res;
- do
+ int res;
+ do
+ {
+ if ( ( res = fscanf( f, "%c %d %c %d %2s\n",
+ &type,
+ &p_transponders[p_scan->i_transponders].i_frequency,
+ &p_transponders[p_scan->i_transponders].c_polarization,
+ &p_transponders[p_scan->i_transponders].i_symbol_rate,
+ psz_fec ) ) != 5 )
{
- if ( ( res = fscanf( f, "%c %d %c %d %2s\n",
- &type,
- &p_transponders[p_scan->i_transponders].i_frequency,
- &p_transponders[p_scan->i_transponders].c_polarization,
- &p_transponders[p_scan->i_transponders].i_symbol_rate,
- psz_fec ) ) != 5 )
- {
- msg_Dbg( p_scan->p_obj, "error parsing transponder from file" );
- continue;
- }
+ msg_Dbg( p_scan->p_obj, "error parsing transponder from file" );
+ continue;
+ }
- /* decode fec */
- char psz_fec_list[] = "1/22/33/44/55/66/77/88/9";
- char *p_fec = strstr( psz_fec_list, psz_fec );
- if ( !p_fec )
- p_transponders[p_scan->i_transponders].i_fec = 9; /* FEC_AUTO */
- else
- p_transponders[p_scan->i_transponders].i_fec = 1 + ( ( p_fec-psz_fec_list ) / 3 );
+ /* decode fec */
+ char psz_fec_list[] = "1/22/33/44/55/66/77/88/9";
+ char *p_fec = strstr( psz_fec_list, psz_fec );
+ if ( !p_fec )
+ p_transponders[p_scan->i_transponders].i_fec = 9; /* FEC_AUTO */
+ else
+ p_transponders[p_scan->i_transponders].i_fec = 1 + ( ( p_fec-psz_fec_list ) / 3 );
- p_scan->i_transponders++;
+ p_scan->i_transponders++;
- scan_dvbs_transponder_t *p_realloc = realloc( p_transponders, ( p_scan->i_transponders + 1 ) * sizeof(*p_realloc) );
- if( p_realloc )
- p_transponders = p_realloc;
- else
- res = EOF;
- } while (res != EOF);
+ scan_dvbs_transponder_t *p_realloc = realloc( p_transponders, ( p_scan->i_transponders + 1 ) * sizeof(*p_realloc) );
+ if( p_realloc )
+ p_transponders = p_realloc;
+ else
+ res = EOF;
+ } while (res != EOF);
- msg_Dbg( p_scan->p_obj, "parsed %d transponders from config", p_scan->i_transponders);
+ msg_Dbg( p_scan->p_obj, "parsed %d transponders from config", p_scan->i_transponders);
- fclose( f );
- p_scan->p_transponders = p_transponders;
- }
- else
- {
- 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;
- }
+ p_scan->p_transponders = p_transponders;
+ fclose( f );
free( p_scan->parameter.sat_info.psz_name );
- free( psz_path );
}
if( p_scan->i_index < p_scan->i_transponders )
More information about the vlc-commits
mailing list