--- a/hotspot/src/share/vm/logging/logPrefix.hpp Tue May 10 03:37:36 2016 +0000
+++ b/hotspot/src/share/vm/logging/logPrefix.hpp Mon May 09 15:46:12 2016 +0200
@@ -96,9 +96,14 @@
#define LOG_PREFIX(fn, ...) \
template <> struct LogPrefix<__VA_ARGS__> { \
static size_t prefix(char* buf, size_t len) { \
- DEBUG_ONLY(buf[0] = '\0';) \
size_t ret = fn(buf, len); \
- assert(ret == strlen(buf), "Length mismatch ret (" SIZE_FORMAT ") != buf length (" SIZE_FORMAT ")", ret, strlen(buf)); \
+ /* Either prefix did fit (strlen(buf) == ret && ret < len) */ \
+ /* or the prefix didn't fit in buffer (ret > len && strlen(buf) < len) */ \
+ assert(ret == 0 || strlen(buf) < len, \
+ "Buffer overrun by prefix function."); \
+ assert(ret == 0 || strlen(buf) == ret || ret >= len, \
+ "Prefix function should return length of prefix written," \
+ " or the intended length of prefix if the buffer was too small."); \
return ret; \
} \
};