From c9d861ff5dc74dd59701713f85a56a12e01fdd25 Mon Sep 17 00:00:00 2001 From: mjreno Date: Mon, 21 Aug 2023 10:34:07 -0400 Subject: [PATCH] fix(lak,sfr,uzf): fix nullptr when deallocating package in validate mode (#1331) Co-authored-by: mjreno --- src/Model/GroundWaterFlow/gwf3lak8.f90 | 8 +++++--- src/Model/GroundWaterFlow/gwf3sfr8.f90 | 8 +++++--- src/Model/GroundWaterFlow/gwf3uzf8.f90 | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Model/GroundWaterFlow/gwf3lak8.f90 b/src/Model/GroundWaterFlow/gwf3lak8.f90 index 3c839ad81b0..fbaac89658d 100644 --- a/src/Model/GroundWaterFlow/gwf3lak8.f90 +++ b/src/Model/GroundWaterFlow/gwf3lak8.f90 @@ -4644,9 +4644,11 @@ subroutine lak_da(this) ! ! -- package csv table if (this%ipakcsv > 0) then - call this%pakcsvtab%table_da() - deallocate (this%pakcsvtab) - nullify (this%pakcsvtab) + if (associated(this%pakcsvtab)) then + call this%pakcsvtab%table_da() + deallocate (this%pakcsvtab) + nullify (this%pakcsvtab) + end if end if ! ! -- scalars diff --git a/src/Model/GroundWaterFlow/gwf3sfr8.f90 b/src/Model/GroundWaterFlow/gwf3sfr8.f90 index a7fcee06672..ab21074fbdf 100644 --- a/src/Model/GroundWaterFlow/gwf3sfr8.f90 +++ b/src/Model/GroundWaterFlow/gwf3sfr8.f90 @@ -2704,9 +2704,11 @@ subroutine sfr_da(this) ! ! -- deallocate package csv table if (this%ipakcsv > 0) then - call this%pakcsvtab%table_da() - deallocate (this%pakcsvtab) - nullify (this%pakcsvtab) + if (associated(this%pakcsvtab)) then + call this%pakcsvtab%table_da() + deallocate (this%pakcsvtab) + nullify (this%pakcsvtab) + end if end if ! ! -- deallocate scalars diff --git a/src/Model/GroundWaterFlow/gwf3uzf8.f90 b/src/Model/GroundWaterFlow/gwf3uzf8.f90 index 51204499414..3c1202787f9 100644 --- a/src/Model/GroundWaterFlow/gwf3uzf8.f90 +++ b/src/Model/GroundWaterFlow/gwf3uzf8.f90 @@ -2796,9 +2796,11 @@ subroutine uzf_da(this) ! ! -- package csv table if (this%ipakcsv > 0) then - call this%pakcsvtab%table_da() - deallocate (this%pakcsvtab) - nullify (this%pakcsvtab) + if (associated(this%pakcsvtab)) then + call this%pakcsvtab%table_da() + deallocate (this%pakcsvtab) + nullify (this%pakcsvtab) + end if end if ! ! -- deallocate scalars