--- a/hotspot/src/share/vm/prims/jvm.cpp Mon Nov 17 09:36:40 2014 +0100
+++ b/hotspot/src/share/vm/prims/jvm.cpp Mon Nov 17 11:26:43 2014 -0500
@@ -2593,6 +2593,10 @@
if ((intptr_t)count <= 0) return -1;
int result = vsnprintf(str, count, fmt, args);
+ // Note: on truncation vsnprintf(3) on Unix returns numbers of
+ // characters which would have been written had the buffer been large
+ // enough; on Windows, it returns -1. We handle both cases here and
+ // always return -1, and perform null termination.
if ((result > 0 && (size_t)result >= count) || result == -1) {
str[count - 1] = '\0';
result = -1;