From e27a95e92097a601baa9b0e9dd6fcc5013c863fa Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Mon, 21 Dec 2020 22:44:00 +0900 Subject: [PATCH] d3dx9: Avoid closing invalid handles. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50373 Signed-off-by: Akihiro Sagawa Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- dlls/d3dx9_36/util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/d3dx9_36/util.c b/dlls/d3dx9_36/util.c index 5be9083360a..39afe6740c0 100644 --- a/dlls/d3dx9_36/util.c +++ b/dlls/d3dx9_36/util.c @@ -134,8 +134,10 @@ HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) return S_OK; error: - CloseHandle(hmapping); - CloseHandle(hfile); + if (hmapping) + CloseHandle(hmapping); + if (hfile != INVALID_HANDLE_VALUE) + CloseHandle(hfile); return HRESULT_FROM_WIN32(GetLastError()); }