mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
Return nullptr from gridByIndex for an out-of-range index
A 3D pick can report a grid index that is not valid for the view grid, which read past the end of the local grids in release builds. Call stack: [0] performCrashLogging at ResInsight/ApplicationExeCode/RiaMainTools.cpp:178 [1] manageSegFailureSA(int, siginfo_t*, void*) at ResInsight/ApplicationExeCode/RiaMainTools.cpp:310 [3] cvf::ref<RigLocalGrid>::p() at ResInsight/Fwk/VizFwk/LibCore/cvfObject.inl:307 [4] RiuCellAndNncPickEventHandler::handle3dPickEvent(Ric3dPickEvent const&) at ResInsight/ApplicationLibCode/UserInterface/RiuCellAndNncPickEventHandler.cpp:397 [5] RiuViewerCommands::handlePickAction(int, int, QFlags<Qt::KeyboardModifier>) at ResInsight/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp:756 [9] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1879 [15] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1879 [26] main at ResInsight/ApplicationExeCode/RiaMain.cpp:267 [27] __libc_start_main at :0
This commit is contained in:
1 parent
596bbb8fe1
commit
a7cecc2ecf
2 files changed
+15
-2
No files matched your search
@@ -294,7 +294,7 @@ void RigMainGrid::computeCachedData( std::string* aabbTreeInfo )
|
||||
RigGridBase* RigMainGrid::gridByIndex( size_t localGridIndex )
|
||||
{
|
||||
if ( localGridIndex == 0 ) return this;
|
||||
CAF_ASSERT( localGridIndex - 1 < m_localGrids.size() );
|
||||
if ( localGridIndex - 1 >= m_localGrids.size() ) return nullptr;
|
||||
return m_localGrids[localGridIndex - 1].p();
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ RigGridBase* RigMainGrid::gridByIndex( size_t localGridIndex )
|
||||
const RigGridBase* RigMainGrid::gridByIndex( size_t localGridIndex ) const
|
||||
{
|
||||
if ( localGridIndex == 0 ) return this;
|
||||
CAF_ASSERT( localGridIndex - 1 < m_localGrids.size() );
|
||||
if ( localGridIndex - 1 >= m_localGrids.size() ) return nullptr;
|
||||
return m_localGrids[localGridIndex - 1].p();
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,19 @@ TEST( RigEclipseCaseDataTest, WellCellsInGridIsRecomputedWhenGridSizeChanges )
|
||||
EXPECT_EQ( mainGrid->cellCount(), wellCells->size() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// A pick on an intersection can report a grid index from another case than the one in the view
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RigMainGridTest, GridByIndexOutOfRangeReturnsNull )
|
||||
{
|
||||
cvf::ref<RigMainGrid> mainGrid = new RigMainGrid;
|
||||
mainGrid->setCellCounts( cvf::Vec3st( 2, 2, 2 ) );
|
||||
|
||||
EXPECT_EQ( mainGrid.p(), mainGrid->gridByIndex( 0 ) );
|
||||
EXPECT_EQ( nullptr, mainGrid->gridByIndex( 1 ) );
|
||||
EXPECT_EQ( nullptr, mainGrid->gridByIndex( cvf::UNDEFINED_SIZE_T ) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user