< prev index next >

src/hotspot/share/services/diagnosticArgument.cpp

Print this page

        

*** 135,144 **** --- 135,146 ---- } } template <> void DCmdArgument<jlong>::destroy_value() { } + PRAGMA_DIAG_PUSH + PRAGMA_STRINGOP_TRUNCATION_IGNORED template <> void DCmdArgument<bool>::parse_value(const char* str, size_t len, TRAPS) { // len is the length of the current token starting at str if (len == 0) { set_value(true);
*** 149,165 **** --- 151,172 ---- set_value(false); } else { ResourceMark rm; char* buf = NEW_RESOURCE_ARRAY(char, len + 1); + + // This code would be warned as "stringop-truncatino" by GCC 8 or later. + // So we avoid it via PRAGMA_STRINGOP_TRUNCATION_IGNORED macro. strncpy(buf, str, len); + buf[len] = '\0'; Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(), "Boolean parsing error in command argument '%s'. Could not parse: %s.\n", _name, buf); } } } + PRAGMA_DIAG_POP template <> void DCmdArgument<bool>::init_value(TRAPS) { if (has_default()) { this->parse_value(_default_string, strlen(_default_string), THREAD); if (HAS_PENDING_EXCEPTION) {
< prev index next >