Skip to content

Commit 2106908

Browse files
authored
fix(core): add null checks before closing BinaryReader/FileStream in update process (#6507)
fix(Get-PESubsystem): Ensure resources are closed only if initialized. Fixes #6506
1 parent befdb20 commit 2106908

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/core.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ function Get-PESubsystem($filePath) {
1616
} catch {
1717
return -1
1818
} finally {
19-
$binaryReader.Close()
20-
$fileStream.Close()
19+
if ($null -ne $binaryReader) { $binaryReader.Close() }
20+
if ($null -ne $fileStream) { $fileStream.Close() }
2121
}
2222
}
2323

0 commit comments

Comments
 (0)