Index: trunk/src/VBox/Runtime/common/string/strformat.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/string/strformat.cpp	(revision 90686)
+++ trunk/src/VBox/Runtime/common/string/strformat.cpp	(revision 90779)
@@ -45,4 +45,34 @@
 #include "internal/string.h"
 
+
+/**
+ * Deals with bad pointers.
+ */
+static size_t rtStrFormatBadPointer(size_t cch, PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, int cchWidth,
+                                    unsigned fFlags, void const *pvStr, char szTmp[64], const char *pszTag, int cchTag)
+{
+    static char const s_szNull[] = "<NULL>";
+    int               cchStr     = !pvStr ? sizeof(s_szNull) - 1 : 1 + sizeof(void *) * 2 + cchTag + 1;
+
+    if (!(fFlags & RTSTR_F_LEFT))
+        while (--cchWidth >= cchStr)
+            cch += pfnOutput(pvArgOutput, " ", 1);
+
+    cchWidth -= cchStr;
+    if (!pvStr)
+        cch += pfnOutput(pvArgOutput, s_szNull, sizeof(s_szNull) - 1);
+    else
+    {
+        cch += pfnOutput(pvArgOutput, "<", 1);
+        cchStr = RTStrFormatNumber(&szTmp[0], (uintptr_t)pvStr, 16, sizeof(char *) * 2, 0, RTSTR_F_ZEROPAD);
+        cch += pfnOutput(pvArgOutput, szTmp, cchStr);
+        cch += pfnOutput(pvArgOutput, pszTag, cchTag);
+        cch += pfnOutput(pvArgOutput, ">", 1);
+    }
+
+    while (--cchWidth >= 0)
+        cch += pfnOutput(pvArgOutput, " ", 1);
+    return cch;
+}
 
 
@@ -514,81 +544,81 @@
                         {
                             /* utf-16 -> utf-8 */
-                            int         cchStr;
-                            PCRTUTF16   pwszStr = va_arg(args, PRTUTF16);
-
-                            if (!VALID_PTR(pwszStr))
-                            {
-                                static RTUTF16  s_wszNull[] = {'<', 'N', 'U', 'L', 'L', '>', '\0' };
-                                pwszStr = s_wszNull;
-                            }
-                            cchStr = _strnlenUtf16(pwszStr, (unsigned)cchPrecision);
-                            if (!(fFlags & RTSTR_F_LEFT))
+                            PCRTUTF16 pwszStr = va_arg(args, PCRTUTF16);
+                            if (RT_VALID_PTR(pwszStr))
+                            {
+                                int cwcStr = _strnlenUtf16(pwszStr, (unsigned)cchPrecision);
+                                if (!(fFlags & RTSTR_F_LEFT))
+                                    while (--cchWidth >= cwcStr)
+                                        cch += pfnOutput(pvArgOutput, " ", 1);
+                                cchWidth -= cwcStr;
+                                while (cwcStr-- > 0)
+                                {
+/** @todo \#ifndef IN_RC*/
+#ifdef IN_RING3
+                                    RTUNICP Cp;
+                                    RTUtf16GetCpEx(&pwszStr, &Cp);
+                                    char *pszEnd = RTStrPutCp(szTmp, Cp);
+                                    *pszEnd = '\0';
+                                    cch += pfnOutput(pvArgOutput, szTmp, pszEnd - szTmp);
+#else
+                                    char ch = (char)*pwszStr++;
+                                    cch += pfnOutput(pvArgOutput, &ch, 1);
+#endif
+                                }
+                                while (--cchWidth >= 0)
+                                    cch += pfnOutput(pvArgOutput, " ", 1);
+                            }
+                            else
+                                cch = rtStrFormatBadPointer(cch, pfnOutput, pvArgOutput, cchWidth, fFlags,
+                                                            pwszStr, szTmp, RT_STR_TUPLE("!BadStrW"));
+                        }
+                        else if (chArgSize == 'L')
+                        {
+                            /* unicp -> utf8 */
+                            PCRTUNICP puszStr = va_arg(args, PCRTUNICP);
+                            if (RT_VALID_PTR(puszStr))
+                            {
+                                int cchStr = _strnlenUni(puszStr, (unsigned)cchPrecision);
+                                if (!(fFlags & RTSTR_F_LEFT))
+                                    while (--cchWidth >= cchStr)
+                                        cch += pfnOutput(pvArgOutput, " ", 1);
+
+                                cchWidth -= cchStr;
+                                while (cchStr-- > 0)
+                                {
+/** @todo \#ifndef IN_RC*/
+#ifdef IN_RING3
+                                    char *pszEnd = RTStrPutCp(szTmp, *puszStr++);
+                                    cch += pfnOutput(pvArgOutput, szTmp, pszEnd - szTmp);
+#else
+                                    char ch = (char)*puszStr++;
+                                    cch += pfnOutput(pvArgOutput, &ch, 1);
+#endif
+                                }
+                                while (--cchWidth >= 0)
+                                    cch += pfnOutput(pvArgOutput, " ", 1);
+                            }
+                            else
+                                cch = rtStrFormatBadPointer(cch, pfnOutput, pvArgOutput, cchWidth, fFlags,
+                                                            puszStr, szTmp, RT_STR_TUPLE("!BadStrU"));
+                        }
+                        else
+                        {
+                            const char *pszStr = va_arg(args, const char *);
+                            if (RT_VALID_PTR(pszStr))
+                            {
+                                int cchStr = _strnlen(pszStr, (unsigned)cchPrecision);
+                                if (!(fFlags & RTSTR_F_LEFT))
+                                    while (--cchWidth >= cchStr)
+                                        cch += pfnOutput(pvArgOutput, " ", 1);
+
+                                cch += pfnOutput(pvArgOutput, pszStr, cchStr);
+
                                 while (--cchWidth >= cchStr)
                                     cch += pfnOutput(pvArgOutput, " ", 1);
-                            cchWidth -= cchStr;
-                            while (cchStr-- > 0)
-                            {
-/** @todo \#ifndef IN_RC*/
-#ifdef IN_RING3
-                                RTUNICP Cp;
-                                RTUtf16GetCpEx(&pwszStr, &Cp);
-                                char *pszEnd = RTStrPutCp(szTmp, Cp);
-                                *pszEnd = '\0';
-                                cch += pfnOutput(pvArgOutput, szTmp, pszEnd - szTmp);
-#else
-                                char ch = (char)*pwszStr++;
-                                cch += pfnOutput(pvArgOutput, &ch, 1);
-#endif
-                            }
-                            while (--cchWidth >= 0)
-                                cch += pfnOutput(pvArgOutput, " ", 1);
-                        }
-                        else if (chArgSize == 'L')
-                        {
-                            /* unicp -> utf8 */
-                            int         cchStr;
-                            PCRTUNICP   puszStr = va_arg(args, PCRTUNICP);
-
-                            if (!VALID_PTR(puszStr))
-                            {
-                                static RTUNICP s_uszNull[] = {'<', 'N', 'U', 'L', 'L', '>', '\0' };
-                                puszStr = s_uszNull;
-                            }
-                            cchStr = _strnlenUni(puszStr, (unsigned)cchPrecision);
-                            if (!(fFlags & RTSTR_F_LEFT))
-                                while (--cchWidth >= cchStr)
-                                    cch += pfnOutput(pvArgOutput, " ", 1);
-
-                            cchWidth -= cchStr;
-                            while (cchStr-- > 0)
-                            {
-/** @todo \#ifndef IN_RC*/
-#ifdef IN_RING3
-                                char *pszEnd = RTStrPutCp(szTmp, *puszStr++);
-                                cch += pfnOutput(pvArgOutput, szTmp, pszEnd - szTmp);
-#else
-                                char ch = (char)*puszStr++;
-                                cch += pfnOutput(pvArgOutput, &ch, 1);
-#endif
-                            }
-                            while (--cchWidth >= 0)
-                                cch += pfnOutput(pvArgOutput, " ", 1);
-                        }
-                        else
-                        {
-                            int   cchStr;
-                            const char *pszStr = va_arg(args, char*);
-
-                            if (!VALID_PTR(pszStr))
-                                pszStr = "<NULL>";
-                            cchStr = _strnlen(pszStr, (unsigned)cchPrecision);
-                            if (!(fFlags & RTSTR_F_LEFT))
-                                while (--cchWidth >= cchStr)
-                                    cch += pfnOutput(pvArgOutput, " ", 1);
-
-                            cch += pfnOutput(pvArgOutput, pszStr, cchStr);
-
-                            while (--cchWidth >= cchStr)
-                                cch += pfnOutput(pvArgOutput, " ", 1);
+                            }
+                            else
+                                cch = rtStrFormatBadPointer(cch, pfnOutput, pvArgOutput, cchWidth, fFlags,
+                                                            pszStr, szTmp, RT_STR_TUPLE("!BadStr"));
                         }
                         break;
@@ -727,6 +757,6 @@
                             }
                         }
-                        cchNum = RTStrFormatNumber((char *)&szTmp, u64Value, uBase, cchWidth, cchPrecision, fFlags);
-                        cch += pfnOutput(pvArgOutput, (char *)&szTmp, cchNum);
+                        cchNum = RTStrFormatNumber(&szTmp[0], u64Value, uBase, cchWidth, cchPrecision, fFlags);
+                        cch += pfnOutput(pvArgOutput, &szTmp[0], cchNum);
                         break;
                     }
