hwdec_vaapi: close file descriptors even if surface export fails

otherwise they can leak
This commit is contained in:
Aaron Boxer 2023-01-26 14:20:11 -05:00 committed by sfan5
parent 881f820fdf
commit 588d66fb25
1 changed files with 7 additions and 0 deletions

View File

@ -245,6 +245,12 @@ static int mapper_init(struct ra_hwdec_mapper *mapper)
return 0;
}
static void close_file_descriptors(VADRMPRIMESurfaceDescriptor desc)
{
for (int i = 0; i < desc.num_objects; i++)
close(desc.objects[i].fd);
}
static int mapper_map(struct ra_hwdec_mapper *mapper)
{
struct priv_owner *p_owner = mapper->owner->priv;
@ -261,6 +267,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper)
if (!CHECK_VA_STATUS_LEVEL(mapper, "vaExportSurfaceHandle()",
p_owner->probing_formats ? MSGL_DEBUG : MSGL_ERR))
{
close_file_descriptors(desc);
goto err;
}
vaSyncSurface(display, va_surface_id(mapper->src));