Commit a6b0ee0b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Equalizer: fix invalid sprintf() usage - fixes #2424

parent c15dfbb2
...@@ -505,52 +505,52 @@ static int PresetCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -505,52 +505,52 @@ static int PresetCallback( vlc_object_t *p_this, char const *psz_cmd,
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
char *psz_preset = newval.psz_string; char *psz_preset = newval.psz_string;
char psz_newbands[120];
memset( psz_newbands, 0, 120 ); if( !*psz_preset || p_sys->i_band != 10 )
return VLC_SUCCESS;
if( *psz_preset && p_sys->i_band == 10 ) for( unsigned i = 0; eqz_preset_10b[i] != NULL; i++ )
{ {
int i; if( !strcasecmp( eqz_preset_10b[i]->psz_name, psz_preset ) )
/* */
for( i = 0; eqz_preset_10b[i] != NULL; i++ )
{ {
if( !strcasecmp( eqz_preset_10b[i]->psz_name, psz_preset ) ) char *psz_newbands = NULL;
p_sys->f_gamp *= pow( 10, eqz_preset_10b[i]->f_preamp / 20.0 );
for( int j = 0; j < p_sys->i_band; j++ )
{ {
int j; lldiv_t d;
p_sys->f_gamp *= pow( 10, eqz_preset_10b[i]->f_preamp / 20.0 ); char *psz;
for( j = 0; j < p_sys->i_band; j++ )
{ p_sys->f_amp[j] = EqzConvertdB( eqz_preset_10b[i]->f_amp[j] );
lldiv_t div; d = lldiv( eqz_preset_10b[i]->f_amp[j] * 10000000, 10000000 );
p_sys->f_amp[j] = EqzConvertdB( if( asprintf( &psz, "%s %lld.%07llu",
eqz_preset_10b[i]->f_amp[j] ); psz_newbands ? psz_newbands : "",
div = lldiv( eqz_preset_10b[i]->f_amp[j] * 10000000, d.quot, d.rem ) == -1 )
10000000 );
sprintf( psz_newbands, "%s %"PRId64".%07u", psz_newbands,
(int64_t)div.quot, (unsigned int) div.rem );
}
if( p_sys->b_first == false )
{ {
var_SetString( p_aout, "equalizer-bands", psz_newbands ); free( psz_newbands );
var_SetFloat( p_aout, "equalizer-preamp", return VLC_ENOMEM;
eqz_preset_10b[i]->f_preamp );
} }
else psz_newbands = psz;
{
p_sys->psz_newbands = strdup( psz_newbands );
p_sys->f_newpreamp = eqz_preset_10b[i]->f_preamp;
}
break;
} }
} if( p_sys->b_first == false )
if( eqz_preset_10b[i] == NULL ) {
{ var_SetString( p_aout, "equalizer-bands", psz_newbands );
msg_Err( p_aout, "equalizer preset '%s' not found", psz_preset ); var_SetFloat( p_aout, "equalizer-preamp",
msg_Dbg( p_aout, "full list:" ); eqz_preset_10b[i]->f_preamp );
for( i = 0; eqz_preset_10b[i] != NULL; i++ ) free( psz_newbands );
msg_Dbg( p_aout, " - '%s'", eqz_preset_10b[i]->psz_name ); }
else
{
p_sys->psz_newbands = psz_newbands;
p_sys->f_newpreamp = eqz_preset_10b[i]->f_preamp;
}
return VLC_SUCCESS;
} }
} }
msg_Err( p_aout, "equalizer preset '%s' not found", psz_preset );
msg_Info( p_aout, "full list:" );
for( unsigned i = 0; eqz_preset_10b[i] != NULL; i++ )
msg_Info( p_aout, " - '%s'", eqz_preset_10b[i]->psz_name );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
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