hotspot/src/share/vm/prims/jvm.cpp
changeset 27667 3c814b51da6c
parent 27612 7201412afbd0
child 27674 00cabfc45357
equal deleted inserted replaced
27666:0b48f6967bbc 27667:3c814b51da6c
  2591 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) {
  2591 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) {
  2592   // see bug 4399518, 4417214
  2592   // see bug 4399518, 4417214
  2593   if ((intptr_t)count <= 0) return -1;
  2593   if ((intptr_t)count <= 0) return -1;
  2594 
  2594 
  2595   int result = vsnprintf(str, count, fmt, args);
  2595   int result = vsnprintf(str, count, fmt, args);
       
  2596   // Note: on truncation vsnprintf(3) on Unix returns numbers of
       
  2597   // characters which would have been written had the buffer been large
       
  2598   // enough; on Windows, it returns -1. We handle both cases here and
       
  2599   // always return -1, and perform null termination.
  2596   if ((result > 0 && (size_t)result >= count) || result == -1) {
  2600   if ((result > 0 && (size_t)result >= count) || result == -1) {
  2597     str[count - 1] = '\0';
  2601     str[count - 1] = '\0';
  2598     result = -1;
  2602     result = -1;
  2599   }
  2603   }
  2600 
  2604