[vlc-commits] [Git][videolan/vlc][3.0.x] direct3d11: fix potential double free

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jun 27 10:10:52 UTC 2025



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
c96fecdf by Steve Lhomme at 2025-06-24T11:34:50+02:00
direct3d11: fix potential double free

When the pool size doesn't match the input size, the p_sys->resource may change.
We just want to release the ID3D11Resource we got from OpenSharedResource1().

Issue consecutive to 833b02552a6d6055f1ed1d5f84827ac213db5774.

- - - - -


1 changed file:

- modules/video_output/win32/direct3d11.c


Changes:

=====================================
modules/video_output/win32/direct3d11.c
=====================================
@@ -1122,6 +1122,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
 
         ID3D11DeviceContext* copyContext = sys->d3d_dev.d3dcontext;
         ID3D11Resource* copyResource = p_sys->resource[KNOWN_DXGI_INDEX];
+        ID3D11Resource* newResource = NULL;
 
         if (is_d3d11_opaque(picture->format.i_chroma) && sys->d3d_dev.d3dcontext != p_sys->context)
         {
@@ -1145,7 +1146,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
             hr = ID3D11Device_QueryInterface(psysDev, &IID_ID3D11Device1, (void**)&d3d11VLC1);
             if (SUCCEEDED(hr))
             {
-                hr = ID3D11Device1_OpenSharedResource1(d3d11VLC1, sys->sharedHandle, &IID_ID3D11Resource, (void**)&copyResource);
+                hr = ID3D11Device1_OpenSharedResource1(d3d11VLC1, sys->sharedHandle, &IID_ID3D11Resource, (void**)&newResource);
                 ID3D11Device1_Release(d3d11VLC1);
             }
             ID3D11Device_Release(psysDev);
@@ -1156,6 +1157,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
                 return;
             }
 
+            copyResource = newResource;
             copyContext = p_sys->context;
         }
 
@@ -1200,9 +1202,9 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
             }
         }
 
-        if (copyResource != p_sys->resource[KNOWN_DXGI_INDEX])
+        if (newResource != NULL)
             // shared resource
-            ID3D11Resource_Release(copyResource);
+            ID3D11Resource_Release(newResource);
     }
 
     if (subpicture) {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c96fecdf230d18f802222abc3267d645f2120800

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c96fecdf230d18f802222abc3267d645f2120800
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list