#14452 Guard against fracture without fracture template

RimFracture::startMD() and endMD() dereferenced the fracture template without checking for null. A fracture with no template assigned crashed MSW completion export, which calls startMD() for all completions on a well path.
This commit is contained in:
Magne Sjaastad committed 2026-08-05 09:20:49 +02:00
1 parent 3023e6e335
commit dd16739a37
3 files changed
+37 -1

No files matched your search

@@ -363,7 +363,7 @@ cvf::Color3f RimFracture::defaultComponentColor() const
//--------------------------------------------------------------------------------------------------
double RimFracture::startMD() const
{
if ( fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH )
if ( fractureTemplate() && fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH )
{
return fractureMD() - 0.5 * perforationLength();
}
@@ -378,6 +378,8 @@ double RimFracture::startMD() const
//--------------------------------------------------------------------------------------------------
double RimFracture::endMD() const
{
if ( !fractureTemplate() ) return startMD();
if ( fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH )
{
return startMD() + perforationLength();
@@ -74,6 +74,7 @@ set(SOURCE_UNITTEST_FILES
${CMAKE_CURRENT_LIST_DIR}/Intersect-Test.cpp
${CMAKE_CURRENT_LIST_DIR}/RifPerforationIntervalReader-Test.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathCompletions-Test.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathFracture-Test.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathValve-Test.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathGeometryDef-Test.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellRftPlot-Test.cpp
@@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2026 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "gtest/gtest.h"
#include "RimWellPathFracture.h"
//--------------------------------------------------------------------------------------------------
/// A fracture without a fracture template must report a measured depth range without crashing
//--------------------------------------------------------------------------------------------------
TEST( RimWellPathFractureTest, MeasuredDepthWithoutFractureTemplate )
{
RimWellPathFracture fracture;
fracture.setMeasuredDepth( 100.0 );
EXPECT_DOUBLE_EQ( 100.0, fracture.startMD() );
EXPECT_DOUBLE_EQ( 100.0, fracture.endMD() );
}