From b0eda47b26d41e767a26523cc316a990e6067679 Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Sat, 6 May 2023 17:52:08 -0700 Subject: [PATCH] prevent infinite-loop on EOF --- core/os/file_windows.odin | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/os/file_windows.odin b/core/os/file_windows.odin index 9b1050cb0..9d62014af 100644 --- a/core/os/file_windows.odin +++ b/core/os/file_windows.odin @@ -243,11 +243,6 @@ pread :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { if !win32.ReadFile(h, raw_data(buf), u32(len(buf)), &done, &o) { e = Errno(win32.GetLastError()) done = 0 - - // this makes behavior between *nix and windows consistent when EOF is hit - if e == ERROR_EOF { - e = 0 - } } return int(done), e } @@ -292,6 +287,10 @@ read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Errno) { b, offset := data, offset for len(b) > 0 { m, e := pread(fd, b, offset) + if e == ERROR_EOF { + err = 0 + break + } if e != 0 { err = e break