Closing opened handles to avoid resource leak. (#51950)
authorArtem Kliatchkine <artem.kliatchkine@gmail.com>
Tue, 25 May 2021 16:11:50 +0000 (18:11 +0200)
committerGitHub <noreply@github.com>
Tue, 25 May 2021 16:11:50 +0000 (09:11 -0700)
SymReader::InitializeFromFile opens file handles which were not closed causing resource leaks on each call.

Fix #50422

Co-authored-by: Artem Kliatchkine <eldog@rambler.ru>
src/coreclr/debug/ildbsymlib/symread.cpp

index dc12d4f..168d84f 100644 (file)
@@ -722,6 +722,12 @@ SymReader::InitializeFromFile(
     }
 
 ErrExit:
+    if (hMod)
+        UnmapViewOfFile(hMod);
+    if (hMapFile != INVALID_HANDLE_VALUE)
+        CloseHandle(hMapFile);
+    if (hFile != INVALID_HANDLE_VALUE)
+        CloseHandle(hFile);
 
     return hr;
 }