From 4c33f953fe808882e8dc7e2df0b7f23356f649ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Sch=C3=BCtt?= Date: Wed, 29 Jan 2025 21:46:12 +0100 Subject: [PATCH] DeePMD: Fix memory leak in deepmd_model_load --- src/deepmd_wrapper.F | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/deepmd_wrapper.F b/src/deepmd_wrapper.F index b80f10f3bc..9826102dd3 100644 --- a/src/deepmd_wrapper.F +++ b/src/deepmd_wrapper.F @@ -68,6 +68,12 @@ CONTAINS TYPE(C_PTR) :: DeepPotCheckOK END FUNCTION DeepPotCheckOK END INTERFACE + INTERFACE + SUBROUTINE DeleteChar(ptr) BIND(C, name="DP_DeleteChar") + IMPORT :: C_PTR + TYPE(C_PTR), VALUE :: ptr + END SUBROUTINE DeleteChar + END INTERFACE CALL timeset(routineN, handle) @@ -85,6 +91,7 @@ CONTAINS IF (error_f_ptr(i) == C_NULL_CHAR) EXIT error_str(i:i) = error_f_ptr(i) END DO + CALL DeleteChar(error_c_ptr) IF (LEN_TRIM(error_str) > 0) CPABORT(TRIM(error_str)) #else CPABORT("CP2K was compiled without libdeepmd_c library.")