Skip to content

Commit

Permalink
FIX: Error writing files of exact size 0xffffffff on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jul 5, 2022
1 parent 39347f4 commit 3c43f44
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/os/win32/dev-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,10 @@ static BOOL Seek_File_64(REBREQ *file)
size_low = GetFileSize(file->handle, &size_high);
if (size_low == 0xffffffff) {
result = GetLastError();
file->error = -RFE_BAD_WRITE;
return DR_ERROR;
if (result != NO_ERROR) {
file->error = -RFE_BAD_WRITE;
return DR_ERROR;
}
}

file->file.size = ((i64)size_high << 32) + (i64)size_low;
Expand Down
21 changes: 21 additions & 0 deletions src/tests/test-issue-2282.r3
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Rebol [
Title: "Test for issue #2282"
Url: https://github.com/Oldes/Rebol-issues/issues/2282
]

file: %issue-2282
try [delete file]
print either all [
not error? try [
a: make binary! n: 268435391
insert/dup a #"a" n
loop 16 [write/append file a]

b: make binary! n: 1039
insert/dup b #"b" n
write/append file b
]
(size? file) = to integer! #{FFFFFFFF}
]["OK"]["FAILED"]
wait 1
try [delete file]

0 comments on commit 3c43f44

Please sign in to comment.