From 22f9053401102f9e36345e468052d01eaff59e32 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 9 Jun 2026 14:06:22 +0200 Subject: [PATCH] #14193 Guard additional null sub-accessor derefs in pick handling findCellAndGridIndex and ijkFromCellIndex shared the same latent null-pointer pattern as the context menu crash: the outer case/view was null-checked, but a sub-accessor that can also return nullptr was dereferenced without a guard. These are reachable from the same pick and context-menu flow when a case is still loading, in a comparison view, or being torn down. - findCellAndGridIndex: guard mainGrid() and geoMechData() - ijkFromCellIndex: guard eclipseCaseData() (matching isRadialGrid) and femParts() --- ApplicationLibCode/UserInterface/RiuViewerCommands.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp index 1a1903d0e3..9e2f18d6b9 100644 --- a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp @@ -1118,13 +1118,13 @@ void RiuViewerCommands::findCellAndGridIndex( Rim3dView* m eclipseCase = dynamic_cast( mainOrComparisonView->ownerCase() ); } - if ( eclipseCase ) + if ( eclipseCase && eclipseCase->mainGrid() ) { const RigCell& cell = eclipseCase->mainGrid()->cell( globalCellIndex ); *cellIndex = cell.gridLocalCellIndex(); *gridIndex = cell.hostGrid()->gridIndex(); } - else if ( geomechCase ) + else if ( geomechCase && geomechCase->geoMechData() ) { RigFemPartCollection* parts = geomechCase->geoMechData()->femParts(); auto [partId, elementIdx] = parts->partIdAndElementIndex( globalCellIndex ); @@ -1223,12 +1223,12 @@ void RiuViewerCommands::ijkFromCellIndex( Rim3dView* mainOrComparisonView, size_ RimEclipseView* eclipseView = dynamic_cast( mainOrComparisonView ); RimGeoMechView* geomView = dynamic_cast( mainOrComparisonView ); - if ( eclipseView && eclipseView->eclipseCase() ) + if ( eclipseView && eclipseView->eclipseCase() && eclipseView->eclipseCase()->eclipseCaseData() ) { eclipseView->eclipseCase()->eclipseCaseData()->grid( gridIdx )->ijkFromCellIndex( cellIndex, i, j, k ); } - if ( geomView && geomView->geoMechCase() ) + if ( geomView && geomView->geoMechCase() && geomView->femParts() ) { geomView->femParts()->part( gridIdx )->getOrCreateStructGrid()->ijkFromCellIndex( cellIndex, i, j, k ); }