Skip to content

Commit 111e486

Browse files
committed
Destroy API object in case of error
1 parent c31218f commit 111e486

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/dftd4/api.f90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ function load_rational_damping_api(verror, charptr, atm) &
440440
type(c_ptr) :: vparam
441441
type(vp_param), pointer :: param
442442
real(wp), allocatable :: s9
443+
class(damping_param), allocatable :: tmp
443444

444445
if (debug) print'("[Info]",1x, a)', "load_rational_damping"
445446

@@ -451,13 +452,14 @@ function load_rational_damping_api(verror, charptr, atm) &
451452
call c_f_character(charptr, method)
452453

453454
if (atm) s9 = 1.0_wp
454-
allocate(param)
455-
call get_rational_damping(method, param%ptr, s9)
456-
if (.not.allocated(param%ptr)) then
455+
call get_rational_damping(method, tmp, s9)
456+
if (.not.allocated(tmp)) then
457457
call fatal_error(error%ptr, "Functional '"//method//"' not known")
458458
return
459459
end if
460460

461+
allocate(param)
462+
call move_alloc(tmp, param%ptr)
461463
vparam = c_loc(param)
462464

463465
end function load_rational_damping_api

0 commit comments

Comments
 (0)