[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] Fix #484 [Win64]Cannot save and load image files with a heap whose size is more than 0xff ff ff ff (~4.1GB) (#485)

Jakob Reschke notifications at github.com
Sat Apr 11 19:44:49 UTC 2020


@j4yk commented on this pull request.



>    position = sqImageFilePosition(h);
-  ReadFile((HANDLE)(h-1), (LPVOID) ptr, count*sz, &dwReallyRead, NULL);
-  while(dwReallyRead != (DWORD)(count*sz)) {
-    DWORD err = GetLastError();
-    if(sqMessageBox(MB_ABORTRETRYIGNORE, TEXT("Squeak Warning"),TEXT("Image file read problem (%d out of %d bytes read)"), dwReallyRead, count*sz)
-       == IDABORT) return (dwReallyRead / sz);
-    sqImageFileSeek(h, position);
-    ReadFile((HANDLE)(h-1), (LPVOID) ptr, count*sz, &dwReallyRead, NULL);
+  while (reallyRead != totalToRead) {
+    DWORD toRead = (totalToRead - reallyRead) > (size_t)MAX_DWORD ? MAX_DWORD : totalToRead - reallyRead;
+    BOOL ret = ReadFile((HANDLE)(h - 1), (LPVOID)((sqInt)ptr + (sqInt)reallyRead), toRead, &dwReallyRead, NULL);
+    reallyRead += dwReallyRead;
+
+    if (!ret | dwReallyRead != toRead) {

Not sure whether this is a bug or "clever" code to use the bitwise or. I suggest using the boolean operators (&& and ||) instead for clarity.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/485#pullrequestreview-391795210
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20200411/eda8e0f0/attachment.html>


More information about the Vm-dev mailing list