Index: /trunk/src/VBox/Runtime/common/string/RTStrSplit.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/string/RTStrSplit.cpp	(revision 85344)
+++ /trunk/src/VBox/Runtime/common/string/RTStrSplit.cpp	(revision 85345)
@@ -46,24 +46,32 @@
 
     /* Determine the number of paths in buffer first. */
-    size_t       cch    = cbStrings - 1;
-    char const  *pszTmp = pcszStrings;
+    size_t      cch     = cbStrings - 1;
+    char const *pcszTmp = pcszStrings;
+    const char *pcszEnd = RTStrEnd(pcszTmp, RTSTR_MAX);
+    char const *pcszNext;
     const size_t cchSep = strlen(pcszSeparator);
+          size_t cchNext;
     while (cch > 0)
     {
-        char const *pszNext = RTStrStr(pszTmp, pcszSeparator);
-        if (!pszNext)
+        pcszNext = RTStrStr(pcszTmp, pcszSeparator);
+        if (!pcszNext)
             break;
-        const size_t cchNext = pszNext - pszTmp;
+        cchNext = pcszNext - pcszTmp;
         if (cchNext + cchSep > cch)
             break;
-        pszTmp += cchNext + cchSep;
-        cch    -= cchNext + cchSep;
+        pcszNext += cchSep;
+        pcszTmp  += cchNext + cchSep;
+        cch      -= cchNext + cchSep;
         if (cchNext)
             ++cStrings;
     }
 
+    if (pcszTmp != pcszEnd) /* Do we need to take a trailing string without separator into account? */
+        cStrings++;
+
     if (!cStrings)
     {
-        *pcStrings = 0;
+        *ppapszStrings = NULL;
+        *pcStrings     = 0;
         return VINF_SUCCESS;
     }
@@ -76,17 +84,15 @@
 
     cch    = cbStrings - 1;
-    pszTmp = pcszStrings;
+    pcszTmp = pcszStrings;
 
-    for (size_t i = 0; i < 3;)
+    for (size_t i = 0; i < cStrings;)
     {
-        char const *pszNext = RTStrStr(pszTmp, pcszSeparator);
-        if (!pszNext)
-            break;
-        const size_t cchNext = pszNext - pszTmp;
-        if (cchNext + cchSep > cch)
-            break;
+        pcszNext = RTStrStr(pcszTmp, pcszSeparator);
+        if (!pcszNext)
+            pcszNext = pcszEnd;
+        cchNext = pcszNext - pcszTmp;
         if (cchNext)
         {
-            papszStrings[i] = RTStrDupN(pszTmp, cchNext);
+            papszStrings[i] = RTStrDupN(pcszTmp, cchNext);
             if (!papszStrings[i])
             {
@@ -96,6 +102,6 @@
             i++;
         }
-        pszTmp += cchNext + cchSep;
-        cch    -= cchNext + cchSep;
+        pcszTmp += cchNext + cchSep;
+        cch     -= cchNext + cchSep;
     }
 
Index: /trunk/src/VBox/Runtime/testcase/tstRTStrSplit.cpp
===================================================================
--- /trunk/src/VBox/Runtime/testcase/tstRTStrSplit.cpp	(revision 85344)
+++ /trunk/src/VBox/Runtime/testcase/tstRTStrSplit.cpp	(revision 85345)
@@ -55,11 +55,10 @@
     RTTEST_CHECK_RC(hTest, RTStrSplit(szEmpty, sizeof(szEmpty), "\r\n", &papszStrings, &cStrings), VINF_SUCCESS);
     RTTEST_CHECK(hTest, cStrings == 0);
-    RTTEST_CHECK(hTest, papszStrings == NULL);
 
     /* No separator given. */
     const char szNoSep[] = "foo";
     RTTEST_CHECK_RC(hTest, RTStrSplit(szNoSep, sizeof(szNoSep), "\r\n", &papszStrings, &cStrings), VINF_SUCCESS);
-    RTTEST_CHECK(hTest, cStrings == 0);
-    RTTEST_CHECK(hTest, papszStrings == NULL);
+    RTTEST_CHECK(hTest, cStrings == 1);
+    RTTEST_CHECK(hTest, RTStrICmp(papszStrings[0], "foo") == 0);
 
     /* Single string w/ separator. */
@@ -69,6 +68,6 @@
     RTTEST_CHECK(hTest, papszStrings && RTStrICmp(papszStrings[0], "foo") == 0);
 
-    /* Multiple strings w/ separators. */
-    const char szWithSep2[] = "foo\r\nbar\r\n";
+    /* Multiple strings w/ separator. */
+    const char szWithSep2[] = "foo\r\nbar";
     RTTEST_CHECK_RC(hTest, RTStrSplit(szWithSep2, sizeof(szWithSep2), "\r\n", &papszStrings, &cStrings), VINF_SUCCESS);
     RTTEST_CHECK(hTest, cStrings == 2);
@@ -88,5 +87,5 @@
 
     /* Multiple strings w/ two consequtive separators. */
-    const char szWithSep4[] = "foo\r\nbar\r\n\r\nbaz\r\n";
+    const char szWithSep4[] = "foo\r\nbar\r\n\r\nbaz";
     RTTEST_CHECK_RC(hTest, RTStrSplit(szWithSep4, sizeof(szWithSep4), "\r\n", &papszStrings, &cStrings), VINF_SUCCESS);
     RTTEST_CHECK(hTest, cStrings == 3);
@@ -97,4 +96,13 @@
                         && RTStrICmp(papszStrings[2], "baz") == 0);
 
+    /* Multiple strings w/ trailing separators. */
+    const char szWithSep5[] = "foo\r\nbar\r\n\r\nbaz\r\n\r\n";
+    RTTEST_CHECK_RC(hTest, RTStrSplit(szWithSep5, sizeof(szWithSep5), "\r\n", &papszStrings, &cStrings), VINF_SUCCESS);
+    RTTEST_CHECK(hTest, cStrings == 3);
+    RTTEST_CHECK(hTest,    cStrings == 3
+                        && papszStrings
+                        && RTStrICmp(papszStrings[0], "foo") == 0
+                        && RTStrICmp(papszStrings[1], "bar") == 0
+                        && RTStrICmp(papszStrings[2], "baz") == 0);
     /*
      * Summary.
