hotspot/src/share/vm/prims/jvm.cpp
changeset 27667 3c814b51da6c
parent 27612 7201412afbd0
child 27674 00cabfc45357
--- 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;