diff -r 229ed95d8958 -r 41ef3dc95179 hotspot/src/share/vm/utilities/xmlstream.cpp --- a/hotspot/src/share/vm/utilities/xmlstream.cpp Mon Nov 09 11:35:45 2015 +0000 +++ b/hotspot/src/share/vm/utilities/xmlstream.cpp Mon Oct 26 16:21:37 2015 +0100 @@ -346,13 +346,16 @@ // ------------------------------------------------------------------ void xmlStream::va_done(const char* format, va_list ap) { char buffer[200]; - guarantee(strlen(format) + 10 < sizeof(buffer), "bigger format buffer"); + size_t format_len = strlen(format); + guarantee(format_len + 10 < sizeof(buffer), "bigger format buffer"); const char* kind = format; const char* kind_end = strchr(kind, ' '); - size_t kind_len = (kind_end != NULL) ? (kind_end - kind) : strlen(kind); + size_t kind_len = (kind_end != NULL) ? (kind_end - kind) : format_len; strncpy(buffer, kind, kind_len); strcpy(buffer + kind_len, "_done"); - strcat(buffer, format + kind_len); + if (kind_end != NULL) { + strncat(buffer, format + kind_len, sizeof(buffer) - (kind_len + 5 /* _done */) - 1); + } // Output the trailing event with the timestamp. va_begin_elem(buffer, ap); stamp();