Index: /trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp	(revision 65034)
+++ /trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp	(revision 65035)
@@ -149,4 +149,11 @@
         return;
 
+    Assert(pPCMProps->cBits);
+    size_t cbToClear = cSamples * (pPCMProps->cBits / 8 /* Bytes */);
+    Assert(cbBuf >= cbToClear);
+
+    if (cbBuf < cbToClear)
+        cbToClear = cbBuf;
+
     Log2Func(("pPCMInfo=%p, pvBuf=%p, cSamples=%RU32, fSigned=%RTbool, cBits=%RU8, cShift=%RU8\n",
               pPCMProps, pvBuf, cSamples, pPCMProps->fSigned, pPCMProps->cBits, pPCMProps->cShift));
@@ -154,5 +161,5 @@
     if (pPCMProps->fSigned)
     {
-        memset(pvBuf, 0, cSamples << pPCMProps->cShift);
+        RT_BZERO(pvBuf, cbToClear);
     }
     else
@@ -162,5 +169,5 @@
             case 8:
             {
-                memset(pvBuf, 0x80, cSamples << pPCMProps->cShift);
+                memset(pvBuf, 0x80, cbToClear);
                 break;
             }
@@ -169,11 +176,10 @@
             {
                 uint16_t *p = (uint16_t *)pvBuf;
-                int shift = pPCMProps->cChannels - 1;
-                short s = INT16_MAX;
+                int16_t   s = INT16_MAX;
 
                 if (pPCMProps->fSwapEndian)
                     s = RT_BSWAP_U16(s);
 
-                for (unsigned i = 0; i < cSamples << shift; i++)
+                for (uint32_t i = 0; i < cSamples; i++)
                     p[i] = s;
 
@@ -184,11 +190,10 @@
             {
                 uint32_t *p = (uint32_t *)pvBuf;
-                int shift = pPCMProps->cChannels - 1;
-                int32_t s = INT32_MAX;
+                int32_t   s = INT32_MAX;
 
                 if (pPCMProps->fSwapEndian)
                     s = RT_BSWAP_U32(s);
 
-                for (unsigned i = 0; i < cSamples << shift; i++)
+                for (uint32_t i = 0; i < cSamples; i++)
                     p[i] = s;
 
