src/hotspot/cpu/x86/vm_version_ext_x86.cpp
changeset 51070 2f4c3cac8556
parent 50113 caf115bb98ad
child 54519 a2795025f417
--- a/src/hotspot/cpu/x86/vm_version_ext_x86.cpp	Thu Jul 12 16:30:47 2018 +0200
+++ b/src/hotspot/cpu/x86/vm_version_ext_x86.cpp	Wed Jul 11 16:11:10 2018 +0200
@@ -470,8 +470,8 @@
 }
 
 size_t VM_Version_Ext::cpu_write_support_string(char* const buf, size_t buf_len) {
-  assert(buf != NULL, "buffer is NULL!");
-  assert(buf_len > 0, "buffer len not enough!");
+  guarantee(buf != NULL, "buffer is NULL!");
+  guarantee(buf_len > 0, "buffer len not enough!");
 
   unsigned int flag = 0;
   unsigned int fi = 0;
@@ -481,8 +481,7 @@
 #define WRITE_TO_BUF(string)                                                          \
   {                                                                                   \
     int res = jio_snprintf(&buf[written], buf_len - written, "%s%s", prefix, string); \
-    if (res < 0 || (size_t) res >= buf_len - 1) {                                     \
-      buf[buf_len-1] = '\0';                                                          \
+    if (res < 0) {                                                                    \
       return buf_len - 1;                                                             \
     }                                                                                 \
     written += res;                                                                   \
@@ -592,7 +591,7 @@
     _cpuid_info.ext_cpuid1_edx);
 
   if (outputLen < 0 || (size_t) outputLen >= buf_len - 1) {
-    buf[buf_len-1] = '\0';
+    if (buf_len > 0) { buf[buf_len-1] = '\0'; }
     return OS_ERR;
   }