Skip to content

Commit 2525e92

Browse files
authored
Merge pull request #18689 from babsingh/18688_043
(0.43) Add a NULL check on threadObject in destroyThreadData
2 parents a61fe6f + 2888ed9 commit 2525e92

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

runtime/jvmti/jvmtiHook.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,19 +221,21 @@ static void
221221
destroyThreadData(J9JVMTIEnv *j9env, J9VMThread *vmThread)
222222
{
223223
j9object_t threadObject = vmThread->threadObject;
224+
if (NULL != threadObject) {
224225
#if JAVA_SPEC_VERSION >= 19
225-
void *tlsArray = J9OBJECT_ADDRESS_LOAD(vmThread, threadObject, vmThread->javaVM->tlsOffset);
226+
void *tlsArray = J9OBJECT_ADDRESS_LOAD(vmThread, threadObject, vmThread->javaVM->tlsOffset);
226227

227-
if (NULL != tlsArray)
228+
if (NULL != tlsArray)
228229
#endif /* JAVA_SPEC_VERSION >= 19 */
229-
{
230-
/* Deallocate the thread data block for this environment/thread pair, if it exists. */
231-
J9JVMTIThreadData *threadData = jvmtiTLSGet(vmThread, threadObject, j9env->tlsKey);
232-
if (NULL != threadData) {
233-
jvmtiTLSSet(vmThread, threadObject, j9env->tlsKey, NULL);
234-
omrthread_monitor_enter(j9env->threadDataPoolMutex);
235-
pool_removeElement(j9env->threadDataPool, threadData);
236-
omrthread_monitor_exit(j9env->threadDataPoolMutex);
230+
{
231+
/* Deallocate the thread data block for this environment/thread pair, if it exists. */
232+
J9JVMTIThreadData *threadData = jvmtiTLSGet(vmThread, threadObject, j9env->tlsKey);
233+
if (NULL != threadData) {
234+
jvmtiTLSSet(vmThread, threadObject, j9env->tlsKey, NULL);
235+
omrthread_monitor_enter(j9env->threadDataPoolMutex);
236+
pool_removeElement(j9env->threadDataPool, threadData);
237+
omrthread_monitor_exit(j9env->threadDataPoolMutex);
238+
}
237239
}
238240
}
239241
}

0 commit comments

Comments
 (0)