Index: /trunk/src/VBox/Main/src-client/VideoRec.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/VideoRec.cpp	(revision 65176)
+++ /trunk/src/VBox/Main/src-client/VideoRec.cpp	(revision 65177)
@@ -525,8 +525,8 @@
                 delete pStream->pEBML;
 
+            it = pCtx->vecStreams.erase(it);
+
             RTMemFree(pStream);
             pStream = NULL;
-
-            it = pCtx->vecStreams.erase(it);
         }
 
@@ -568,5 +568,6 @@
     RTSemEventDestroy(pCtx->TermEvent);
 
-    for (VideoRecStreams::iterator it = pCtx->vecStreams.begin(); it != pCtx->vecStreams.end(); it++)
+    VideoRecStreams::iterator it = pCtx->vecStreams.begin();
+    while (it != pCtx->vecStreams.end())
     {
         PVIDEORECSTREAM pStream = (*it);
@@ -591,7 +592,17 @@
         }
 
-        delete pStream->pEBML;
-    }
-
+        if (pStream->pEBML)
+        {
+            delete pStream->pEBML;
+            pStream->pEBML = NULL;
+        }
+
+        it = pCtx->vecStreams.erase(it);
+
+        RTMemFree(pStream);
+        pStream = NULL;
+    }
+
+    Assert(pCtx->vecStreams.empty());
     RTMemFree(pCtx);
 
