Skip to content

Commit 22607fe

Browse files
committed
Fix null-pointer crash in TimeSeriesManager%get_time_series
BndTsHashTable is only allocated by HashBndTimeSeries(), which tsmanager_df() calls only when numtsfiles > 0. In a simulation with no TS6 files, the hash table stays unassociated. If a list-input value that should be numeric or a time-series name fails to parse as numeric (e.g. a malformed AUX or boundname column), get_time_series() dereferences that null pointer directly, crashing with SIGSEGV instead of falling through to the intended "Expected numeric value or time-series name, but found '...'" error. Guard the hash-table lookup with an associated() check, matching the existing pattern in the sibling GetLink() function in this same file. With no TS files loaded, no time-series name can match by definition, so returning "not found" is exactly correct -- this lets the intended error path fire instead of crashing. Verified with a debug build (-fcheck=all): before the fix, a malformed LAK PACKAGEDATA aux value reproducibly segfaults; after, MF6 reports the expected input-parsing error and terminates cleanly.
1 parent 95c88c1 commit 22607fe

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/Utilities/TimeSeries/TimeSeriesManager.f90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,11 @@ function get_time_series(this, name) result(res)
463463
! Get index from hash table, get time series from TsContainers,
464464
! and assign result to time series contained in link.
465465
res => null()
466-
indx = this%BndTsHashTable%get(name)
467-
if (indx > 0) then
468-
res => this%TsContainers(indx)%timeSeries
466+
if (associated(this%BndTsHashTable)) then
467+
indx = this%BndTsHashTable%get(name)
468+
if (indx > 0) then
469+
res => this%TsContainers(indx)%timeSeries
470+
end if
469471
end if
470472
end function get_time_series
471473

0 commit comments

Comments
 (0)