From 0b4680eb6f67cbb1a9e33e208863866eba17d372 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Wed, 20 Dec 2023 16:31:26 -0500 Subject: [PATCH] Fix catching by value Fixed: - https://github.com/deepmodeling/deepmd-kit/security/code-scanning/1229 - https://github.com/deepmodeling/deepmd-kit/security/code-scanning/1230 - https://github.com/deepmodeling/deepmd-kit/security/code-scanning/1231 - https://github.com/deepmodeling/deepmd-kit/security/code-scanning/1232 --- source/api_cc/src/DeepPot.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/api_cc/src/DeepPot.cc b/source/api_cc/src/DeepPot.cc index 018c3aca09..bb39a9fd60 100644 --- a/source/api_cc/src/DeepPot.cc +++ b/source/api_cc/src/DeepPot.cc @@ -474,7 +474,7 @@ void DeepPot::init(const std::string& model, ntypes = get_scalar("descrpt_attr/ntypes"); try { ntypes_spin = get_scalar("spin_attr/ntypes_spin"); - } catch (deepmd::deepmd_exception) { + } catch (const deepmd::deepmd_exception) { ntypes_spin = 0; } dfparam = get_scalar("fitting_attr/dfparam"); @@ -488,7 +488,7 @@ void DeepPot::init(const std::string& model, if (daparam > 0) { try { aparam_nall = get_scalar("fitting_attr/aparam_nall"); - } catch (deepmd::deepmd_exception) { + } catch (const deepmd::deepmd_exception) { aparam_nall = false; } } else { @@ -1331,7 +1331,7 @@ void DeepPotModelDevi::init(const std::vector& models, ntypes = get_scalar("descrpt_attr/ntypes"); try { ntypes_spin = get_scalar("spin_attr/ntypes_spin"); - } catch (deepmd::deepmd_exception) { + } catch (const deepmd::deepmd_exception) { ntypes_spin = 0; } dfparam = get_scalar("fitting_attr/dfparam"); @@ -1345,7 +1345,7 @@ void DeepPotModelDevi::init(const std::vector& models, if (daparam > 0) { try { aparam_nall = get_scalar("fitting_attr/aparam_nall"); - } catch (deepmd::deepmd_exception) { + } catch (const deepmd::deepmd_exception) { aparam_nall = false; } } else {