fix a critical bug in windows.osproc leading to resource leaks and blocking IO [backport] (#14296)

This commit is contained in:
Timothee Cour 2020-05-11 02:14:21 -07:00 • committed by GitHub
commit d11cb9d495
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 1 deletions

View file

@ -441,7 +441,11 @@ when defined(Windows) and not defined(useNimRtl):
handle: Handle
atTheEnd: bool
proc hsClose(s: Stream) = discard # nothing to do here
proc hsClose(s: Stream) =
# xxx here + elsewhere: check instead of discard; ignoring errors leads to
# hard to track bugs
discard FileHandleStream(s).handle.closeHandle
proc hsAtEnd(s: Stream): bool = return FileHandleStream(s).atTheEnd
proc hsReadData(s: Stream, buffer: pointer, bufLen: int): int =