< prev index next >
test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp
Print this page
*** 46,78 ****
pEnv->ReleaseStringUTFChars(src, pStr);
}
struct MethodName * getMethodName(jvmtiEnv * pJvmtiEnv, jmethodID method) {
! char * szName;
! char * szSignature;
jclass clazz;
! struct MethodName * mn;
if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodName(method, &szName, NULL, NULL))) {
! return NULL;
}
if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodDeclaringClass(method, &clazz))) {
! NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szName));
! return NULL;
}
if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetClassSignature(clazz, &szSignature, NULL))) {
! NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szName));
! return NULL;
}
mn = (MethodName*) malloc(sizeof(MethodNameStruct));
strncpy(mn->methodName, szName, sizeof(mn->methodName));
strncpy(mn->classSig, szSignature, sizeof(mn->classSig));
NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szName));
NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szSignature));
return mn;
}
--- 46,86 ----
pEnv->ReleaseStringUTFChars(src, pStr);
}
struct MethodName * getMethodName(jvmtiEnv * pJvmtiEnv, jmethodID method) {
! char * szName = NULL;
! char * szSignature = NULL;
jclass clazz;
! struct MethodName * mn = NULL;
if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodName(method, &szName, NULL, NULL))) {
! goto out;
}
if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodDeclaringClass(method, &clazz))) {
! goto out;
}
if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetClassSignature(clazz, &szSignature, NULL))) {
! goto out;
! }
!
! if (strlen(szName) + 1 > sizeof(mn->methodName) ||
! strlen(szSignature) + 1 > sizeof(mn->classSig)) {
! goto out;
}
mn = (MethodName*) malloc(sizeof(MethodNameStruct));
+ if (mn == NULL) {
+ goto out;
+ }
+
strncpy(mn->methodName, szName, sizeof(mn->methodName));
strncpy(mn->classSig, szSignature, sizeof(mn->classSig));
+ out:
NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szName));
NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szSignature));
return mn;
}
< prev index next >