8333149: ubsan : memset on nullptr target detected in jvmtiEnvBase.cpp get_object_monitor_usage

Reviewed-by: sspitsyn, mdoerr
This commit is contained in:
Matthias Baesken 2024-05-29 12:38:51 +00:00
parent fed2b56017
commit 43a2f17342

View File

@ -1557,8 +1557,12 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec
// this object has a heavyweight monitor
// null out memory for robustness
memset(ret.waiters, 0, ret.waiter_count * sizeof(jthread *));
memset(ret.notify_waiters, 0, ret.notify_waiter_count * sizeof(jthread *));
if (ret.waiters != nullptr) {
memset(ret.waiters, 0, ret.waiter_count * sizeof(jthread *));
}
if (ret.notify_waiters != nullptr) {
memset(ret.notify_waiters, 0, ret.notify_waiter_count * sizeof(jthread *));
}
if (ret.waiter_count > 0) { // we have contending threads waiting to enter/re-enter the monitor
// identify threads waiting to enter and re-enter the monitor