[vlc-commits] direct3d11: fix leak and potential crash on region mapping errors

Steve Lhomme git at videolan.org
Fri Apr 13 13:01:26 CEST 2018


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Apr 13 12:31:03 2018 +0200| [deca42f933b53f9eef2f3da80650131d12ce1d49] | committer: Hugo Beauzée-Luyssen

direct3d11: fix leak and potential crash on region mapping errors

(cherry picked from commit d2575e5ebc63212f8fdb4e0d337fcaeabe093db6)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=deca42f933b53f9eef2f3da80650131d12ce1d49
---

 modules/video_output/win32/direct3d11.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 39bb746ff1..07bbeec554 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -3163,7 +3163,10 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
             err = CommonUpdatePicture(quad_picture, NULL, mappedResource.pData, mappedResource.RowPitch);
             if (err != VLC_SUCCESS) {
                 msg_Err(vd, "Failed to set the buffer on the SPU picture" );
+                ID3D11DeviceContext_Unmap(sys->d3d_dev.d3dcontext, ((d3d_quad_t *) quad_picture->p_sys)->picSys.resource[KNOWN_DXGI_INDEX], 0);
                 picture_Release(quad_picture);
+                if ((*region)[i] == quad_picture)
+                    (*region)[i] = NULL;
                 continue;
             }
 
@@ -3173,6 +3176,8 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
         } else {
             msg_Err(vd, "Failed to map the SPU texture (hr=0x%lX)", hr );
             picture_Release(quad_picture);
+            if ((*region)[i] == quad_picture)
+                (*region)[i] = NULL;
             continue;
         }
 



More information about the vlc-commits mailing list