Always call CloseHandle in AsmMan::EmitManifest (#50372)
authorOmair Majid <omajid@redhat.com>
Tue, 18 May 2021 00:45:50 +0000 (20:45 -0400)
committerGitHub <noreply@github.com>
Tue, 18 May 2021 00:45:50 +0000 (17:45 -0700)
Unless it's an ERROR_INVALID_HANDLE.

Otherwise, we can leak the file handle.

src/coreclr/ilasm/asmman.cpp

index 87e79e5..2e4b98b 100644 (file)
@@ -1000,8 +1000,9 @@ HRESULT AsmMan::EmitManifest()
                             m_fMResNew[m_dwMResNum] = TRUE;
                             m_dwMResNum++;
                         }
-                        CloseHandle(hFile);
                     }
+
+                    CloseHandle(hFile);
                 }
             }
             if(fOK || ((Assembler*)m_pAssembler)->OnErrGo)