]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
corrected mac-like placing of <about> menu line
[wxWidgets.git] / src / common / string.cpp
index 3606bb9e55e0190367d9dbc8f048b9fbbe8fffe9..fe8480cd452c4676141eb87c8521424e19ae92b1 100644 (file)
@@ -107,7 +107,7 @@ extern const wxChar WXDLLEXPORT *wxEmptyString = &g_strEmpty.dummy;
 //       function wxVsnprintfA (A for ANSI), should also find one for Unicode
 //       strings in Unicode build
 #ifdef __WXMSW__
-    #ifdef __VISUALC__
+    #if defined(__VISUALC__) || defined(wxUSE_NORLANDER_HEADERS)
         #define wxVsnprintfA     _vsnprintf
     #endif
 #else   // !Windows
@@ -200,7 +200,15 @@ extern int WXDLLEXPORT wxVsnprintf(wxChar *buf, size_t len,
 
     return iLen;
 #else // ANSI
-    return wxVsnprintfA(buf, len, format, argptr);
+    // vsnprintf() will not terminate the string with '\0' if there is not
+    // enough place, but we want the string to always be NUL terminated
+    int rc = wxVsnprintfA(buf, len - 1, format, argptr);
+    if ( rc == -1 )
+    {
+        buf[len] = 0;
+    }
+
+    return rc;
 #endif // Unicode/ANSI
 }