Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c	(revision 55622)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c	(revision 55623)
@@ -454,27 +454,32 @@
     CRASSERT(slot < pack_spu.numContexts);
 
-    context = &(pack_spu.context[slot]);
-
-    if (CRPACKSPU_IS_WDDM_CRHGSMI())
-    {
-        thread = context->currentThread;
-        crPackSetContext(thread->packer);
-        CRASSERT(!(thread->packer == curPacker) == !(thread == curThread));
-    }
-    CRASSERT(thread);
+    context = (slot >= 0 && slot < pack_spu.numContexts) ? &(pack_spu.context[slot]) : NULL;
     curContext = curThread ? curThread->currentContext : NULL;
 
-    if (pack_spu.swap)
-        crPackDestroyContextSWAP( context->serverCtx );
-    else
-        crPackDestroyContext( context->serverCtx );
-
-    crStateDestroyContext( context->clientState );
-
-    context->clientState = NULL;
-    context->serverCtx = 0;
-    context->currentThread = NULL;
-
-    crMemset (&context->zvaBufferInfo, 0, sizeof (context->zvaBufferInfo));
+    if (context)
+    {
+        if (CRPACKSPU_IS_WDDM_CRHGSMI())
+        {
+            thread = context->currentThread;
+            if (thread)
+            {
+                crPackSetContext(thread->packer);
+                CRASSERT(!(thread->packer == curPacker) == !(thread == curThread));
+            }
+        }
+
+        if (pack_spu.swap)
+            crPackDestroyContextSWAP( context->serverCtx );
+        else
+            crPackDestroyContext( context->serverCtx );
+
+        crStateDestroyContext( context->clientState );
+
+        context->clientState = NULL;
+        context->serverCtx = 0;
+        context->currentThread = NULL;
+
+        crMemset (&context->zvaBufferInfo, 0, sizeof (context->zvaBufferInfo));
+    }
 
     if (curContext == context)
@@ -503,7 +508,7 @@
 void PACKSPU_APIENTRY packspu_MakeCurrent( GLint window, GLint nativeWindow, GLint ctx )
 {
-    ThreadInfo *thread;
+    ThreadInfo *thread = NULL;
     GLint serverCtx;
-    ContextInfo *newCtx;
+    ContextInfo *newCtx = NULL;
 
     if (!CRPACKSPU_IS_WDDM_CRHGSMI())
@@ -528,4 +533,5 @@
 
         newCtx = &pack_spu.context[slot];
+        CRASSERT(newCtx);
         CRASSERT(newCtx->clientState);  /* verify valid */
 
@@ -539,4 +545,5 @@
         else
         {
+            CRASSERT(thread);
             if (newCtx->fAutoFlush)
             {
