]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
Damn broken pipes.
[wxWidgets.git] / src / common / string.cpp
index 3606bb9e55e0190367d9dbc8f048b9fbbe8fffe9..280e105f2539c09d15fb2b75b1bf7c9ba53e5990 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,12 @@ 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);
+    buf[len] = 0;
+
+    return rc;
 #endif // Unicode/ANSI
 }