Index: /trunk/src/VBox/Runtime/common/checksum/manifest.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/checksum/manifest.cpp	(revision 40373)
+++ /trunk/src/VBox/Runtime/common/checksum/manifest.cpp	(revision 40374)
@@ -451,22 +451,4 @@
     AssertReturn(cFiles > 0, VERR_INVALID_PARAMETER);
 
-    /* Calculate the size necessary for the memory buffer. */
-    size_t cbSize = 0;
-    size_t cbMaxSize = 0;
-    for (size_t i = 0; i < cFiles; ++i)
-    {
-        size_t cbTmp = strlen(RTPathFilename(paFiles[i].pszTestFile)) + strlen(paFiles[i].pszTestDigest) + 10;
-        cbMaxSize = RT_MAX(cbMaxSize, cbTmp);
-        cbSize += cbTmp;
-    }
-
-    /* Create the memory buffer */
-    void *pvBuf = RTMemAlloc(cbSize);
-    if (!pvBuf)
-        return VERR_NO_MEMORY;
-
-    /* Allocate a temporary string buffer. */
-    char * pszTmp = RTStrAlloc(cbMaxSize + 1);
-    size_t cbPos = 0;
     const char *pcszDigestType;
     switch (enmDigestType)
@@ -479,4 +461,29 @@
         default: return VERR_INVALID_PARAMETER;
     }
+
+    /* Calculate the size necessary for the memory buffer. */
+    size_t cbSize = 0;
+    size_t cbMaxSize = 0;
+    for (size_t i = 0; i < cFiles; ++i)
+    {
+        size_t cbTmp = strlen(RTPathFilename(paFiles[i].pszTestFile)) + strlen(paFiles[i].pszTestDigest) + 10;
+        cbMaxSize = RT_MAX(cbMaxSize, cbTmp);
+        cbSize += cbTmp;
+    }
+
+    /* Create the memory buffer */
+    void *pvBuf = RTMemAlloc(cbSize);
+    if (!pvBuf)
+        return VERR_NO_MEMORY;
+
+    /* Allocate a temporary string buffer. */
+    char *pszTmp = RTStrAlloc(cbMaxSize + 1);
+    if (!pszTmp)
+    {
+        RTMemFree(pvBuf);
+        return VERR_NO_MEMORY;
+    }
+    size_t cbPos = 0;
+
     for (size_t i = 0; i < cFiles; ++i)
     {
