[vlc-commits] d3d11: Reorder initializations to avoid potential handle leak
Hugo Beauzée-Luyssen
git at videolan.org
Tue Feb 14 15:30:41 CET 2017
vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Feb 14 15:24:36 2017 +0100| [b0d182cb367dbbe590aee273ec0ceea357479858] | committer: Hugo Beauzée-Luyssen
d3d11: Reorder initializations to avoid potential handle leak
CID #1402713
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b0d182cb367dbbe590aee273ec0ceea357479858
---
modules/video_output/win32/direct3d11.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 301cdcc..ac30f41 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -413,26 +413,23 @@ static void Direct3D11UnmapPoolTexture(picture_t *picture)
#if !VLC_WINSTORE_APP
static int OpenHwnd(vout_display_t *vd)
{
- HINSTANCE hd3d11_dll = LoadLibrary(TEXT("D3D11.DLL"));
- if (!hd3d11_dll) {
+ vout_display_sys_t *sys = vd->sys = calloc(1, sizeof(vout_display_sys_t));
+ if (!sys)
+ return VLC_ENOMEM;
+
+ sys->hd3d11_dll = LoadLibrary(TEXT("D3D11.DLL"));
+ if (!sys->hd3d11_dll) {
msg_Warn(vd, "cannot load d3d11.dll, aborting");
return VLC_EGENERIC;
}
- HINSTANCE hd3dcompiler_dll = Direct3D11LoadShaderLibrary();
- if (!hd3dcompiler_dll) {
+ sys->hd3dcompiler_dll = Direct3D11LoadShaderLibrary();
+ if (!sys->hd3dcompiler_dll) {
msg_Err(vd, "cannot load d3dcompiler.dll, aborting");
Direct3D11Destroy(vd);
return VLC_EGENERIC;
}
- vout_display_sys_t *sys = vd->sys = calloc(1, sizeof(vout_display_sys_t));
- if (!sys)
- return VLC_ENOMEM;
-
- sys->hd3d11_dll = hd3d11_dll;
- sys->hd3dcompiler_dll = hd3dcompiler_dll;
-
sys->OurD3DCompile = (void *)GetProcAddress(sys->hd3dcompiler_dll, "D3DCompile");
if (!sys->OurD3DCompile) {
msg_Err(vd, "Cannot locate reference to D3DCompile in d3dcompiler DLL");
@@ -441,7 +438,7 @@ static int OpenHwnd(vout_display_t *vd)
}
sys->OurD3D11CreateDevice =
- (void *)GetProcAddress(hd3d11_dll, "D3D11CreateDevice");
+ (void *)GetProcAddress(sys->hd3d11_dll, "D3D11CreateDevice");
if (!sys->OurD3D11CreateDevice) {
msg_Err(vd, "Cannot locate reference to D3D11CreateDevice in d3d11 DLL");
Direct3D11Destroy(vd);
More information about the vlc-commits
mailing list