Index: /trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c
===================================================================
--- /trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c	(revision 35265)
+++ /trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c	(revision 35266)
@@ -58,4 +58,5 @@
 #include "product-generated.h"
 #include <xf86.h>
+#include <misc.h>
 
 /* All drivers initialising the SW cursor need this */
@@ -1288,5 +1289,6 @@
      * too large for VRAM as we sometimes have to do this - see comments in
      * VBOXPreInit. */
-    if (offStart + pVBox->cbLine * cHeight > pVBox->cbFramebuffer)
+    if (   offStart + pVBox->cbLine * cHeight > pVBox->cbFramebuffer
+        || pVBox->cbLine * pScrn->virtualY > pVBox->cbFramebuffer)
         fActive = FALSE;
     /* Deactivate the screen if it is outside of the virtual framebuffer and
@@ -1327,4 +1329,5 @@
     VBOXPtr pVBox = VBOXGetRec(pScrn);
     uint64_t cbLine = vboxLineLength(pScrn, width);
+    uint32_t cbOldPixmap;
 
     TRACE_LOG("width=%d, height=%d\n", width, height);
@@ -1344,8 +1347,13 @@
                                 pScrn->depth, vboxBPP(pScrn), cbLine,
                                 pVBox->base);
+    cbOldPixmap = pVBox->cbLine * pScrn->virtualY;
+    if (cbOldPixmap > pVBox->cbFramebuffer)
+        cbOldPixmap = 0;
     pScrn->virtualX = width;
     pScrn->virtualY = height;
     pScrn->displayWidth = vboxDisplayPitch(pScrn, cbLine);
     pVBox->cbLine = cbLine;
+    /* Clear video RAM for esthetic reasons */
+    memset(pVBox->base, 0, max(cbLine * height, cbOldPixmap));
 #ifdef VBOX_DRI
     if (pVBox->useDRI)
