Commit d78c9308 authored by Jean-Paul Saman's avatar Jean-Paul Saman

VAAPI: do not crash when vlc_va_Initialize fails.

Upon failure of vlc_va_Initialize() the error path jumped to the label 'error',
which would call sys->conn->unlock(). However the error path was taken before
sys->conn->lock() was called and even worse sys->conn = NULL in this case. This
would result into crash obviously. Therefor move the 'error' label one line down,
so it only calls the cleanup routions and add a lable 'unlock' for the error paths
that need to unlock first before cleaning up.
parent 9401d8f1
......@@ -149,7 +149,7 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id, int i_count )
int i_profiles_nb = vaMaxNumProfiles( p_va->conn->p_display );
VAProfile *p_profiles_list = calloc( i_profiles_nb, sizeof( VAProfile ) );
if ( !p_profiles_list )
goto error;
goto unlock;
VAStatus status = vaQueryConfigProfiles( p_va->conn->p_display, p_profiles_list, &i_profiles_nb );
if ( status == VA_STATUS_SUCCESS )
{
......@@ -164,7 +164,7 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id, int i_count )
}
free( p_profiles_list );
if ( !b_supported_profile )
goto error;
goto unlock;
/* Create a VA configuration */
VAConfigAttrib attrib;
......@@ -172,16 +172,16 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id, int i_count )
attrib.type = VAConfigAttribRTFormat;
if( vaGetConfigAttributes( p_va->conn->p_display,
i_profile, VAEntrypointVLD, &attrib, 1 ) )
goto error;
goto unlock;
/* Not sure what to do if not, I don't have a way to test */
if( (attrib.value & VA_RT_FORMAT_YUV420) == 0 )
goto error;
goto unlock;
if( vaCreateConfig( p_va->conn->p_display,
i_profile, VAEntrypointVLD, &attrib, 1, &p_va->i_config_id ) )
{
p_va->i_config_id = VA_INVALID_ID;
goto error;
goto unlock;
}
p_va->i_surface_count = i_surface_count;
......@@ -193,8 +193,9 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id, int i_count )
p_va->conn->unlock();
return VLC_SUCCESS;
error:
unlock:
p_va->conn->unlock();
error:
Close(p_va);
return VLC_EGENERIC;
}
......
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