Commit 7f2fcb75 authored by Rémi Duraffort's avatar Rémi Duraffort

Check asprintf return value and avoid one unneeded strdup.

parent f74112d6
...@@ -965,7 +965,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -965,7 +965,7 @@ static void Probe( aout_instance_t * p_aout )
p_sys->i_default_dev = devid_def; p_sys->i_default_dev = devid_def;
var_Create( p_aout, "audio-device", VLC_VAR_INTEGER|VLC_VAR_HASCHOICE ); var_Create( p_aout, "audio-device", VLC_VAR_INTEGER|VLC_VAR_HASCHOICE );
text.psz_string = _("Audio Device"); text.psz_string = (char*)_("Audio Device");
var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL );
for( i = 0; i < p_sys->i_devices; i++ ) for( i = 0; i < p_sys->i_devices; i++ )
...@@ -998,8 +998,9 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -998,8 +998,9 @@ static void Probe( aout_instance_t * p_aout )
/* Add the menu entries */ /* Add the menu entries */
val.i_int = (int)p_devices[i]; val.i_int = (int)p_devices[i];
text.psz_string = strdup( psz_name ); text.psz_string = psz_name;
var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
text.psz_string = NULL;
if( p_sys->i_default_dev == p_devices[i] ) if( p_sys->i_default_dev == p_devices[i] )
{ {
/* The default device is the selected device normally */ /* The default device is the selected device normally */
...@@ -1010,8 +1011,10 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -1010,8 +1011,10 @@ static void Probe( aout_instance_t * p_aout )
if( AudioDeviceSupportsDigital( p_aout, p_devices[i] ) ) if( AudioDeviceSupportsDigital( p_aout, p_devices[i] ) )
{ {
val.i_int = (int)p_devices[i] | AOUT_VAR_SPDIF_FLAG; val.i_int = (int)p_devices[i] | AOUT_VAR_SPDIF_FLAG;
asprintf( &text.psz_string, _("%s (Encoded Output)"), psz_name ); if( asprintf( &text.psz_string, _("%s (Encoded Output)"), psz_name ) != -1 )
{
var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
free( text.psz_string );
if( p_sys->i_default_dev == p_devices[i] && config_GetInt( p_aout, "spdif" ) ) if( p_sys->i_default_dev == p_devices[i] && config_GetInt( p_aout, "spdif" ) )
{ {
/* We selected to prefer SPDIF output if available /* We selected to prefer SPDIF output if available
...@@ -1020,6 +1023,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -1020,6 +1023,7 @@ static void Probe( aout_instance_t * p_aout )
var_Set( p_aout, "audio-device", val ); var_Set( p_aout, "audio-device", val );
} }
} }
}
free( psz_name); free( psz_name);
} }
......
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