mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Issue found by PVS Studio:
Several instances where we utilize a pointer variable without properly testing that they aren't null first.
This commit is contained in:
parent
b24bdfbc8b
commit
3a18819e1e
|
|
@ -502,7 +502,7 @@ void ConvexShape::prepRenderImage( SceneRenderState *state )
|
|||
}
|
||||
*/
|
||||
|
||||
if ( mVertexBuffer.isNull() )
|
||||
if ( mVertexBuffer.isNull() || !state)
|
||||
return;
|
||||
|
||||
// If we don't have a material instance after the override then
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ void RenderMeshExample::prepRenderImage( SceneRenderState *state )
|
|||
createGeometry();
|
||||
|
||||
// If we have no material then skip out.
|
||||
if ( !mMaterialInst )
|
||||
if ( !mMaterialInst || !state)
|
||||
return;
|
||||
|
||||
// If we don't have a material instance after the override then
|
||||
|
|
|
|||
|
|
@ -847,12 +847,13 @@ DefineEngineFunction(linkNamespaces, bool, ( String childNSName, String parentNS
|
|||
|
||||
Namespace *childNS = Namespace::find(childNSSTE);
|
||||
Namespace *parentNS = Namespace::find(parentNSSTE);
|
||||
Namespace *currentParent = childNS->getParent();
|
||||
|
||||
if (!childNS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Namespace *currentParent = childNS->getParent();
|
||||
|
||||
// Link to new NS if applicable
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ void GFXPCD3D9Device::createDirect3D9(LPDIRECT3D9 &d3d9, LPDIRECT3D9EX &d3d9ex)
|
|||
|
||||
if (pfnCreate9Ex)
|
||||
{
|
||||
if (!FAILED(pfnCreate9Ex(D3D_SDK_VERSION, &d3d9ex)) && d3d9ex)
|
||||
if (d3d9ex && !FAILED(pfnCreate9Ex(D3D_SDK_VERSION, &d3d9ex)))
|
||||
d3d9ex->QueryInterface(__uuidof(IDirect3D9), reinterpret_cast<void **>(&d3d9));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1212,7 +1212,7 @@ void GuiWindowCtrl::onMouseUp(const GuiEvent &event)
|
|||
// We're either moving out of a collapse group or moving to another one
|
||||
// Not valid for windows not previously in a group
|
||||
if( mCollapseGroup >= 0 &&
|
||||
( snapType == -1 || ( snapType >= 0 && mCollapseGroup != hitWindow->mCollapseGroup) ) )
|
||||
(snapType == -1 || (hitWindow && snapType >= 0 && mCollapseGroup != hitWindow->mCollapseGroup)))
|
||||
moveFromCollapseGroup();
|
||||
|
||||
// No window to connect to
|
||||
|
|
|
|||
|
|
@ -1755,41 +1755,48 @@ void GuiControl::write(Stream &stream, U32 tabStop, U32 flags)
|
|||
{
|
||||
//note: this will return false if either we, or any of our parents, are non-save controls
|
||||
bool bCanSave = ( flags & IgnoreCanSave ) || ( flags & NoCheckParentCanSave && getCanSave() ) || getCanSaveParent();
|
||||
StringTableEntry steName = mAddGroup->getInternalName();
|
||||
if(bCanSave && mAddGroup && (steName != NULL) && (steName != StringTable->insert("null")) && getName() )
|
||||
|
||||
if (bCanSave && mAddGroup)
|
||||
{
|
||||
MutexHandle handle;
|
||||
handle.lock(mMutex);
|
||||
StringTableEntry steName = mAddGroup->getInternalName();
|
||||
|
||||
// export selected only?
|
||||
if((flags & SelectedOnly) && !isSelected())
|
||||
if ((steName != NULL) && (steName != StringTable->insert("null")) && getName())
|
||||
{
|
||||
for(U32 i = 0; i < size(); i++)
|
||||
(*this)[i]->write(stream, tabStop, flags);
|
||||
MutexHandle handle;
|
||||
handle.lock(mMutex);
|
||||
|
||||
// export selected only?
|
||||
if ((flags & SelectedOnly) && !isSelected())
|
||||
{
|
||||
for (U32 i = 0; i < size(); i++)
|
||||
(*this)[i]->write(stream, tabStop, flags);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
stream.writeTabs(tabStop);
|
||||
char buffer[1024];
|
||||
dSprintf(buffer, sizeof(buffer), "new %s(%s,%s) {\r\n", getClassName(), getName() ? getName() : "", mAddGroup->getInternalName());
|
||||
stream.write(dStrlen(buffer), buffer);
|
||||
writeFields(stream, tabStop + 1);
|
||||
|
||||
if (size())
|
||||
{
|
||||
stream.write(2, "\r\n");
|
||||
for (U32 i = 0; i < size(); i++)
|
||||
(*this)[i]->write(stream, tabStop + 1, flags);
|
||||
}
|
||||
|
||||
stream.writeTabs(tabStop);
|
||||
stream.write(4, "};\r\n");
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
stream.writeTabs(tabStop);
|
||||
char buffer[1024];
|
||||
dSprintf(buffer, sizeof(buffer), "new %s(%s,%s) {\r\n", getClassName(), getName() ? getName() : "", mAddGroup->getInternalName());
|
||||
stream.write(dStrlen(buffer), buffer);
|
||||
writeFields(stream, tabStop + 1);
|
||||
|
||||
if(size())
|
||||
{
|
||||
stream.write(2, "\r\n");
|
||||
for(U32 i = 0; i < size(); i++)
|
||||
(*this)[i]->write(stream, tabStop + 1, flags);
|
||||
}
|
||||
|
||||
stream.writeTabs(tabStop);
|
||||
stream.write(4, "};\r\n");
|
||||
}
|
||||
else if (bCanSave)
|
||||
|
||||
if (bCanSave)
|
||||
Parent::write( stream, tabStop, flags );
|
||||
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
|||
|
|
@ -2655,7 +2655,7 @@ void WorldEditor::renderScene( const RectI &updateRect )
|
|||
|
||||
// Probably should test the entire icon screen-rect instead of just the centerpoint
|
||||
// but would need to move some code from renderScreenObj to here.
|
||||
if ( mDragSelect )
|
||||
if (mDragSelect && selection)
|
||||
if ( mDragRect.pointInRect(sPosI) && !selection->objInSet(obj) )
|
||||
mDragSelected->addObject(obj);
|
||||
|
||||
|
|
|
|||
|
|
@ -737,7 +737,7 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
|
|||
mShaderConsts->set( mMatPrevScreenToWorldSC, tempMat );
|
||||
}
|
||||
|
||||
if ( mAmbientColorSC->isValid() )
|
||||
if (mAmbientColorSC->isValid() && state)
|
||||
{
|
||||
const ColorF &sunlight = state->getAmbientLightColor();
|
||||
Point3F ambientColor( sunlight.red, sunlight.green, sunlight.blue );
|
||||
|
|
|
|||
|
|
@ -203,12 +203,11 @@ void RenderPrePassMgr::addElement( RenderInst *inst )
|
|||
matInst = static_cast<MeshRenderInst*>(inst)->matInst;
|
||||
|
||||
// Skip decals if they don't have normal maps.
|
||||
if ( isDecalMeshInst && !matInst->hasNormalMap() )
|
||||
if (!matInst || isDecalMeshInst && !matInst->hasNormalMap())
|
||||
return;
|
||||
|
||||
// If its a custom material and it refracts... skip it.
|
||||
if ( matInst &&
|
||||
matInst->isCustomMaterial() &&
|
||||
if ( matInst->isCustomMaterial() &&
|
||||
static_cast<CustomMaterial*>( matInst->getMaterial() )->mRefract )
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue