src/share/vm/prims/jvmtiEnv.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File
*** old/src/share/vm/prims/jvmtiEnv.cpp	Thu Aug  4 08:30:59 2016
--- new/src/share/vm/prims/jvmtiEnv.cpp	Thu Aug  4 08:30:57 2016

*** 3558,3589 **** --- 3558,3595 ---- // property_ptr - pre-checked for NULL jvmtiError JvmtiEnv::GetSystemProperties(jint* count_ptr, char*** property_ptr) { jvmtiError err = JVMTI_ERROR_NONE; *count_ptr = Arguments::PropertyList_count(Arguments::system_properties()); + // Get the number of readable properties. + *count_ptr = Arguments::PropertyList_readable_count(Arguments::system_properties()); + // Allocate memory to hold the exact number of readable properties. err = allocate(*count_ptr * sizeof(char *), (unsigned char **)property_ptr); if (err != JVMTI_ERROR_NONE) { return err; } ! int i = 0 ; for (SystemProperty* p = Arguments::system_properties(); p != NULL && i < *count_ptr; p = p->next(), i++) { ! int readable_count = 0; + // Loop through the system properties until all the readable properties are found. + for (SystemProperty* p = Arguments::system_properties(); p != NULL && readable_count < *count_ptr; p = p->next()) { + if (p->is_readable()) { const char *key = p->key(); ! char **tmp_value = *property_ptr+i; ! char **tmp_value = *property_ptr+readable_count++; err = allocate((strlen(key)+1) * sizeof(char), (unsigned char**)tmp_value); if (err == JVMTI_ERROR_NONE) { strcpy(*tmp_value, key); } else { // clean up previously allocated memory. ! for (int j=0; j<i; j++) { ! for (int j=0; j<readable_count; j++) { Deallocate((unsigned char*)*property_ptr+j); } Deallocate((unsigned char*)property_ptr); break; } } + } + assert(err != JVMTI_ERROR_NONE || readable_count == *count_ptr, "Bad readable property count"); return err; } /* end GetSystemProperties */ // property - pre-checked for NULL
*** 3591,3604 **** --- 3597,3608 ---- jvmtiError JvmtiEnv::GetSystemProperty(const char* property, char** value_ptr) { jvmtiError err = JVMTI_ERROR_NONE; const char *value; if (Arguments::is_internal_module_property(property)) { ! return JVMTI_ERROR_NOT_AVAILABLE; } value = Arguments::PropertyList_get_value(Arguments::system_properties(), property); + // Return JVMTI_ERROR_NOT_AVAILABLE if property is not readable or doesn't exist. ! value = Arguments::PropertyList_get_readable_value(Arguments::system_properties(), property); if (value == NULL) { err = JVMTI_ERROR_NOT_AVAILABLE; } else { err = allocate((strlen(value)+1) * sizeof(char), (unsigned char **)value_ptr); if (err == JVMTI_ERROR_NONE) {

src/share/vm/prims/jvmtiEnv.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File