mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 03:24:38 +02:00
6619271: The -Xprintflags causes the VM to segv
Add null checks Reviewed-by: jrose, kvn
This commit is contained in:
parent
1659f11da6
commit
89290f2817
1 changed files with 28 additions and 23 deletions
|
@ -68,18 +68,20 @@ void Flag::print_on(outputStream* st) {
|
||||||
if (is_uintx()) st->print("%-16lu", get_uintx());
|
if (is_uintx()) st->print("%-16lu", get_uintx());
|
||||||
if (is_ccstr()) {
|
if (is_ccstr()) {
|
||||||
const char* cp = get_ccstr();
|
const char* cp = get_ccstr();
|
||||||
const char* eol;
|
if (cp != NULL) {
|
||||||
while ((eol = strchr(cp, '\n')) != NULL) {
|
const char* eol;
|
||||||
char format_buffer[FORMAT_BUFFER_LEN];
|
while ((eol = strchr(cp, '\n')) != NULL) {
|
||||||
size_t llen = pointer_delta(eol, cp, sizeof(char));
|
char format_buffer[FORMAT_BUFFER_LEN];
|
||||||
jio_snprintf(format_buffer, FORMAT_BUFFER_LEN,
|
size_t llen = pointer_delta(eol, cp, sizeof(char));
|
||||||
"%%." SIZE_FORMAT "s", llen);
|
jio_snprintf(format_buffer, FORMAT_BUFFER_LEN,
|
||||||
st->print(format_buffer, cp);
|
"%%." SIZE_FORMAT "s", llen);
|
||||||
st->cr();
|
st->print(format_buffer, cp);
|
||||||
cp = eol+1;
|
st->cr();
|
||||||
st->print("%5s %-35s += ", "", name);
|
cp = eol+1;
|
||||||
|
st->print("%5s %-35s += ", "", name);
|
||||||
|
}
|
||||||
|
st->print("%-16s", cp);
|
||||||
}
|
}
|
||||||
st->print("%-16s", cp);
|
|
||||||
}
|
}
|
||||||
st->print(" %s", kind);
|
st->print(" %s", kind);
|
||||||
st->cr();
|
st->cr();
|
||||||
|
@ -94,18 +96,21 @@ void Flag::print_as_flag(outputStream* st) {
|
||||||
st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx());
|
st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx());
|
||||||
} else if (is_ccstr()) {
|
} else if (is_ccstr()) {
|
||||||
st->print("-XX:%s=", name);
|
st->print("-XX:%s=", name);
|
||||||
// Need to turn embedded '\n's back into separate arguments
|
const char* cp = get_ccstr();
|
||||||
// Not so efficient to print one character at a time,
|
if (cp != NULL) {
|
||||||
// but the choice is to do the transformation to a buffer
|
// Need to turn embedded '\n's back into separate arguments
|
||||||
// and print that. And this need not be efficient.
|
// Not so efficient to print one character at a time,
|
||||||
for (const char* cp = get_ccstr(); *cp != '\0'; cp += 1) {
|
// but the choice is to do the transformation to a buffer
|
||||||
switch (*cp) {
|
// and print that. And this need not be efficient.
|
||||||
default:
|
for (; *cp != '\0'; cp += 1) {
|
||||||
st->print("%c", *cp);
|
switch (*cp) {
|
||||||
break;
|
default:
|
||||||
case '\n':
|
st->print("%c", *cp);
|
||||||
st->print(" -XX:%s=", name);
|
break;
|
||||||
break;
|
case '\n':
|
||||||
|
st->print(" -XX:%s=", name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue