From bfdc84a7445fe978e1ad88b5656171f2f07879b8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 27 Nov 2019 10:17:31 +0100 Subject: [PATCH] #5102 Janitor : Guard null pointer access --- .../RicPasteAsciiDataToSummaryPlotFeature.cpp | 3 +-- .../SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp | 1 + .../SummaryPlotCommands/RicPasteSummaryCaseFeature.cpp | 3 ++- .../SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp | 1 + .../SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp | 1 + .../SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp | 2 ++ .../Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp | 2 ++ .../Commands/WellLogCommands/RicPasteWellLogPlotFeature.cpp | 2 ++ .../Commands/WellLogCommands/RicPasteWellLogTrackFeature.cpp | 1 + 9 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp index a75bcabab0..cf6565b760 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp @@ -54,8 +54,7 @@ bool RicPasteAsciiDataToSummaryPlotFeature::isCommandEnabled() caf::PdmObjectHandle* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); - RimSummaryPlot* summaryPlot = nullptr; - destinationObject->firstAncestorOrThisOfType( summaryPlot ); + if ( !destinationObject ) return false; RimSummaryPlotCollection* summaryPlotCollection = nullptr; destinationObject->firstAncestorOrThisOfType( summaryPlotCollection ); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp index bc64cce823..e67f79f40e 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp @@ -67,6 +67,7 @@ RimEnsembleCurveSet* bool RicPasteEnsembleCurveSetFeature::isCommandEnabled() { caf::PdmObject* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !destinationObject ) return false; RimSummaryPlot* plot = nullptr; RimEnsembleCurveSetCollection* coll = nullptr; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCaseFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCaseFeature.cpp index 3d96ce069e..9bd3640ca3 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCaseFeature.cpp @@ -80,6 +80,7 @@ void RicPasteSummaryCaseFeature::onActionTriggered( bool isChecked ) { caf::PdmObjectHandle* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !destinationObject ) return; std::vector> sourceObjects = RicPasteSummaryCaseFeature::summaryCases(); @@ -162,4 +163,4 @@ void RicPasteSummaryCaseFeature::removeFromSourceCollection( RimSummaryCase* sum sourceSummaryCaseMainCollection->removeCase( summaryCase ); sourceSummaryCaseMainCollection->updateConnectedEditors(); } -} \ No newline at end of file +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp index 4fc3c90756..209cb861b8 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp @@ -69,6 +69,7 @@ bool RicPasteSummaryCrossPlotFeature::isCommandEnabled() { caf::PdmObjectHandle* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !destinationObject ) return false; RimSummaryCrossPlotCollection* plotColl = nullptr; destinationObject->firstAncestorOrThisOfType( plotColl ); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp index e59838e194..16c3069f95 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp @@ -74,6 +74,7 @@ RimSummaryCurve* RicPasteSummaryCurveFeature::copyCurveAndAddToPlot( RimSummaryC bool RicPasteSummaryCurveFeature::isCommandEnabled() { caf::PdmObject* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !destinationObject ) return false; RimSummaryPlot* summaryPlot = nullptr; destinationObject->firstAncestorOrThisOfType( summaryPlot ); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp index cad8b5eca4..ecf4e427b8 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp @@ -70,6 +70,8 @@ bool RicPasteSummaryPlotFeature::isCommandEnabled() caf::PdmObjectHandle* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !destinationObject ) return false; + RimSummaryPlotCollection* plotColl = nullptr; destinationObject->firstAncestorOrThisOfType( plotColl ); if ( !plotColl ) diff --git a/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp index c320e3dbc6..eade406d3b 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp @@ -46,6 +46,7 @@ bool RicPasteWellLogCurveFeature::isCommandEnabled() caf::PdmObjectHandle* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !destinationObject ) return false; RimWellLogTrack* wellLogTrack = nullptr; destinationObject->firstAncestorOrThisOfType( wellLogTrack ); @@ -66,6 +67,7 @@ void RicPasteWellLogCurveFeature::onActionTriggered( bool isChecked ) caf::PdmObjectHandle* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !destinationObject ) return; RimWellLogTrack* wellLogTrack = nullptr; destinationObject->firstAncestorOrThisOfType( wellLogTrack ); diff --git a/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.cpp index 0ba089d542..9b3de3496d 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.cpp @@ -40,6 +40,7 @@ bool RicPasteWellLogPlotFeature::isCommandEnabled() { caf::PdmObjectHandle* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !destinationObject ) return false; RimWellLogPlotCollection* wellLogPlotCollection = nullptr; destinationObject->firstAncestorOrThisOfType( wellLogPlotCollection ); @@ -58,6 +59,7 @@ void RicPasteWellLogPlotFeature::onActionTriggered( bool isChecked ) { caf::PdmObjectHandle* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !destinationObject ) return; RimWellLogPlotCollection* wellLogPlotCollection = nullptr; destinationObject->firstAncestorOrThisOfType( wellLogPlotCollection ); diff --git a/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.cpp index 9c50e0e78f..d4f278f4f9 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.cpp @@ -44,6 +44,7 @@ bool RicPasteWellLogTrackFeature::isCommandEnabled() caf::PdmObjectHandle* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !destinationObject ) return false; RimWellLogPlot* wellLogPlot = nullptr; RimWellRftPlot* rftPlot = nullptr;