From 240df658ee1c453094207fc5057b980699357445 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 7 Aug 2026 15:34:24 +0200 Subject: [PATCH] Guard against missing RFT reader when creating an RFT curve addRftCurve() selects the first Eclipse result case in the project without checking that it has an RFT reader, and then dereferences rftReader(). The command is enabled by hasRftData(), which returns true if any case has a reader, so with several Eclipse cases loaded an enabled menu entry can select a case with no RFT data and crash. Null check the reader before use, matching the guard already used by hasRftData() and hasRftDataForWell(). --- ApplicationLibCode/Commands/RicWellLogTools.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/Commands/RicWellLogTools.cpp b/ApplicationLibCode/Commands/RicWellLogTools.cpp index 2e4674fbf6..7ae8cc2280 100644 --- a/ApplicationLibCode/Commands/RicWellLogTools.cpp +++ b/ApplicationLibCode/Commands/RicWellLogTools.cpp @@ -357,11 +357,16 @@ RimWellLogRftCurve* RicWellLogTools::addRftCurve( RimWellLogTrack* plotTrack, co { curve->setEclipseCase( resultCase ); - auto wellNames = resultCase->rftReader()->wellNames(); - if ( !wellNames.empty() ) + // The case selected above is the first Eclipse result case, which is not guaranteed to have an RFT reader. See + // hasRftData() that requires a reader to be present. + if ( auto* rftReader = resultCase->rftReader() ) { - auto wellName = *( wellNames.begin() ); - curve->setDefaultAddress( wellName ); + auto wellNames = rftReader->wellNames(); + if ( !wellNames.empty() ) + { + auto wellName = *( wellNames.begin() ); + curve->setDefaultAddress( wellName ); + } } } else