diff options
author | Kevin Mitchell <kevmitch@gmail.com> | 2016-02-15 16:23:27 -0800 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2016-02-16 12:36:56 -0800 |
commit | 5d761dd342c724a94bb980cab38bc6f5bf229a85 (patch) | |
tree | c5add03f5e1f5345f5be8983128e7331639de554 | |
parent | d5348a66dc7dcc22d4e6b905caa7e92468f25b94 (diff) | |
download | mpv-5d761dd342c724a94bb980cab38bc6f5bf229a85.tar.bz2 mpv-5d761dd342c724a94bb980cab38bc6f5bf229a85.tar.xz |
dxva2: check for failure of mp_image_new_custom_ref
previously, this may have caused a leak
-rw-r--r-- | video/dxva2.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/video/dxva2.c b/video/dxva2.c index 8e31a45b57..e47f84e8a3 100644 --- a/video/dxva2.c +++ b/video/dxva2.c @@ -74,12 +74,15 @@ struct mp_image *dxva2_new_ref(IDirectXVideoDecoder *decoder, surface->decoder = decoder; IDirectXVideoDecoder_AddRef(surface->decoder); - struct mp_image mpi = {0}; - mp_image_setfmt(&mpi, IMGFMT_DXVA2); - mp_image_set_size(&mpi, w, h); - mpi.planes[3] = (void *)surface->surface; + struct mp_image *mpi = mp_image_new_custom_ref(&(struct mp_image){0}, + surface, dxva2_release_img); + if (!mpi) + 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: dxva2_release_img(surface); return NULL; |