Skip to content

Commit

Permalink
Prevent use of uninitialized variable
Browse files Browse the repository at this point in the history
signed-off-by: Marius Pirvu <[email protected]>
  • Loading branch information
mpirvu committed Jan 2, 2025
1 parent e4332e9 commit 7a2f5e1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions runtime/compiler/optimizer/J9TransformUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2037,16 +2037,16 @@ J9::TransformUtil::transformIndirectLoadChainImpl(TR::Compilation *comp,
return false;
}

void *valuePtr;
J9::TransformUtil::value value;
J9::TransformUtil::value val;
void *valuePtr = NULL;
#if defined(J9VM_OPT_JITSERVER)
if (isServer)
{
// Instead of the recursive dereferenceStructPointerChain, we only consider a single level
// of indirection
void *result = dereferenceStructPointer(baseKnownObject, node, baseExpression,
isBaseStableArray, comp, &value);
valuePtr = &value;
isBaseStableArray, comp, &val);
valuePtr = &val;
if (result != valuePtr)
return false;
}
Expand Down Expand Up @@ -2114,6 +2114,7 @@ J9::TransformUtil::transformIndirectLoadChainImpl(TR::Compilation *comp,
break;
case TR::Address:
{
uintptr_t value = 0;
if (isFinalFieldPointingAtRepresentableNativeStruct(symRef, comp))
{
#if defined(J9VM_OPT_JITSERVER)
Expand All @@ -2124,8 +2125,9 @@ J9::TransformUtil::transformIndirectLoadChainImpl(TR::Compilation *comp,
{
if (changeIndirectLoadIntoConst(node, TR::loadaddr, removedNode, comp))
{
TR_OpaqueClassBlock *value = *(TR_OpaqueClassBlock**)valuePtr;
node->setSymbolReference(comp->getSymRefTab()->findOrCreateClassSymbol(comp->getMethodSymbol(), -1, value));
TR_OpaqueClassBlock *clazz = *(TR_OpaqueClassBlock**)valuePtr;
value = (uintptr_t)clazz;
node->setSymbolReference(comp->getSymRefTab()->findOrCreateClassSymbol(comp->getMethodSymbol(), -1, clazz));
}
else
{
Expand All @@ -2147,7 +2149,7 @@ J9::TransformUtil::transformIndirectLoadChainImpl(TR::Compilation *comp,
#endif /* defined(J9VM_OPT_JITSERVER) */
if (symRef->getReferenceNumber() - comp->getSymRefTab()->getNumHelperSymbols() == TR::SymbolReferenceTable::ramStaticsFromClassSymbol)
{
uintptr_t value = *(uintptr_t*)valuePtr;
value = *(uintptr_t*)valuePtr;
if (changeIndirectLoadIntoConst(node, TR::aconst, removedNode, comp))
{
node->setAddress(value);
Expand All @@ -2171,7 +2173,7 @@ J9::TransformUtil::transformIndirectLoadChainImpl(TR::Compilation *comp,
else
#endif /* defined(J9VM_OPT_JITSERVER) */
{
uintptr_t value = fej9->getReferenceFieldAtAddress((uintptr_t)valuePtr);
value = fej9->getReferenceFieldAtAddress((uintptr_t)valuePtr);
if (value)
{
knotIndex = comp->getKnownObjectTable()->getOrCreateIndexAt(&value,
Expand Down

0 comments on commit 7a2f5e1

Please sign in to comment.