1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-12 01:46:16 +00:00

dxva2: check for failure of mp_image_new_custom_ref

previously, this may have caused a leak
This commit is contained in:
Kevin Mitchell 2016-02-15 16:23:27 -08:00
parent d5348a66dc
commit 5d761dd342

View File

@ -74,12 +74,15 @@ struct mp_image *dxva2_new_ref(IDirectXVideoDecoder *decoder,
surface->decoder = decoder; surface->decoder = decoder;
IDirectXVideoDecoder_AddRef(surface->decoder); IDirectXVideoDecoder_AddRef(surface->decoder);
struct mp_image mpi = {0}; struct mp_image *mpi = mp_image_new_custom_ref(&(struct mp_image){0},
mp_image_setfmt(&mpi, IMGFMT_DXVA2); surface, dxva2_release_img);
mp_image_set_size(&mpi, w, h); if (!mpi)
mpi.planes[3] = (void *)surface->surface; goto fail;
return mp_image_new_custom_ref(&mpi, surface, dxva2_release_img); mp_image_setfmt(mpi, IMGFMT_DXVA2);
mp_image_set_size(mpi, w, h);
mpi->planes[3] = (void *)surface->surface;
return mpi;
fail: fail:
dxva2_release_img(surface); dxva2_release_img(surface);
return NULL; return NULL;