Skip to content

Commit

Permalink
Merge pull request #20422 from babsingh/main7
Browse files Browse the repository at this point in the history
Add a null check for J9JavaVM->bytecodeVerificationData
  • Loading branch information
tajila authored Oct 29, 2024
2 parents 5a6d331 + b7b5b9b commit e577d65
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions runtime/jcl/common/java_lang_invoke_MethodHandleNatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,6 @@ Java_java_lang_invoke_MethodHandleNatives_resolve(
#endif
) {
if (callerClass->classLoader != declaringClass->classLoader) {
J9BytecodeVerificationData *verifyData = vm->bytecodeVerificationData;
U_16 sigOffset = 0;

/* Skip the '[' or 'L' prefix */
Expand All @@ -1313,19 +1312,22 @@ Java_java_lang_invoke_MethodHandleNatives_resolve(
}
if (IS_CLASS_SIGNATURE(J9UTF8_DATA(signature)[sigOffset])) {
sigOffset += 1;
omrthread_monitor_enter(vm->classTableMutex);
UDATA clConstraintResult = verifyData->checkClassLoadingConstraintForNameFunction(
currentThread,
declaringClass->classLoader,
callerClass->classLoader,
J9UTF8_DATA(signature) + sigOffset,
J9UTF8_DATA(signature) + sigOffset,
J9UTF8_LENGTH(signature) - sigOffset - 1, /* -1 to remove the trailing ;*/
true);
omrthread_monitor_exit(vm->classTableMutex);
if (0 != clConstraintResult) {
vmFuncs->setCurrentExceptionUTF(currentThread, J9VMCONSTANTPOOL_JAVALANGLINKAGEERROR, NULL);
goto done;
J9BytecodeVerificationData *verifyData = vm->bytecodeVerificationData;
if (NULL != verifyData) {
omrthread_monitor_enter(vm->classTableMutex);
UDATA clConstraintResult = verifyData->checkClassLoadingConstraintForNameFunction(
currentThread,
declaringClass->classLoader,
callerClass->classLoader,
J9UTF8_DATA(signature) + sigOffset,
J9UTF8_DATA(signature) + sigOffset,
J9UTF8_LENGTH(signature) - sigOffset - 1, /* -1 to remove the trailing ;*/
true);
omrthread_monitor_exit(vm->classTableMutex);
if (0 != clConstraintResult) {
vmFuncs->setCurrentExceptionUTF(currentThread, J9VMCONSTANTPOOL_JAVALANGLINKAGEERROR, NULL);
goto done;
}
}
}
}
Expand Down

0 comments on commit e577d65

Please sign in to comment.