6744783: HotSpot segfaults if given -XX options with an empty string argument

Reviewed-by: kamg, kvn
This commit is contained in:
Volker Simonis 2008-09-25 12:50:51 -07:00 committed by Tom Rodriguez
parent 42be28cece
commit ac161a1e17
3 changed files with 9 additions and 6 deletions

View file

@ -355,8 +355,11 @@ bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, FlagValu
if (result == NULL) return false;
if (!result->is_ccstr()) return false;
ccstr old_value = result->get_ccstr();
char* new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1);
strcpy(new_value, *value);
char* new_value = NULL;
if (*value != NULL) {
new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1);
strcpy(new_value, *value);
}
result->set_ccstr(new_value);
if (result->origin == DEFAULT && old_value != NULL) {
// Prior value is NOT heap allocated, but was a literal constant.