Index: /trunk/src/VBox/Main/ApplianceImplIO.cpp
===================================================================
--- /trunk/src/VBox/Main/ApplianceImplIO.cpp	(revision 33658)
+++ /trunk/src/VBox/Main/ApplianceImplIO.cpp	(revision 33659)
@@ -493,6 +493,4 @@
                 size_t cbAvail = RTCircBufUsed(pInt->pCircBuf);
                 size_t cbMemAllRead = 0;
-                bool fStop = false;
-                bool fEOF = false;
                 /* First loop over all the free memory in the circular
                  * memory buffer (could be turn around at the end). */
@@ -500,5 +498,5 @@
                 {
                     if (   cbMemAllRead == cbAvail
-                        || fStop == true)
+                        || fLoop == false)
                         break;
                     char *pcBuf;
@@ -521,14 +519,5 @@
                         if (RT_FAILURE(rc))
                         {
-                            fStop = true;
                             fLoop = false;
-                            break;
-                        }
-                        if (cbWritten == 0)
-                        {
-                            fStop = true;
-                            fLoop = false;
-                            fEOF = true;
-//                            RTPrintf("EOF\n");
                             break;
                         }
@@ -537,5 +526,6 @@
                     }
                     /* Update the SHA1 context with the next data block. */
-                    if (pInt->pSha1Storage->fCreateDigest)
+                    if (   RT_SUCCESS(rc)
+                        && pInt->pSha1Storage->fCreateDigest)
                         RTSha1Update(&pInt->ctx, pcBuf, cbAllWritten);
                     /* Mark the block as empty. */
@@ -554,6 +544,4 @@
                 size_t cbAvail = RTCircBufFree(pInt->pCircBuf);
                 size_t cbMemAllWrite = 0;
-                bool fStop = false;
-                bool fEOF = false;
                 /* First loop over all the available memory in the circular
                  * memory buffer (could be turn around at the end). */
@@ -561,5 +549,5 @@
                 {
                     if (   cbMemAllWrite == cbAvail
-                        || fStop == true)
+                        || fLoop == false)
                         break;
                     char *pcBuf;
@@ -582,14 +570,12 @@
                         if (RT_FAILURE(rc))
                         {
-                            fStop = true;
                             fLoop = false;
                             break;
                         }
+                        /* This indicates end of file. Stop reading. */
                         if (cbRead == 0)
                         {
-                            fStop = true;
                             fLoop = false;
-                            fEOF = true;
-//                            RTPrintf("EOF\n");
+                            ASMAtomicWriteBool(&pInt->fEOF, true);
                             break;
                         }
@@ -598,5 +584,6 @@
                     }
                     /* Update the SHA1 context with the next data block. */
-                    if (pInt->pSha1Storage->fCreateDigest)
+                    if (   RT_SUCCESS(rc)
+                        && pInt->pSha1Storage->fCreateDigest)
                         RTSha1Update(&pInt->ctx, pcBuf, cbAllRead);
                     /* Mark the block as full. */
@@ -604,6 +591,4 @@
                     cbMemAllWrite += cbAllRead;
                 }
-                if (fEOF)
-                    ASMAtomicWriteBool(&pInt->fEOF, true);
                 /* Reset the thread status and signal the main thread that we
                  * are finished. Use CmpXchg, so we not overwrite other states
