Skip to content

Commit 434fcb7

Browse files
pxlxingliangdyzhengcaic99
authored
fix: delete hpsi before new one in operator.h (#1196)
* fix: delete hpsi before new one in operator.h * Update source/module_hamilt/operator.h Co-authored-by: Chun Cai <[email protected]> Co-authored-by: dyzheng <[email protected]> Co-authored-by: Chun Cai <[email protected]>
1 parent 8b7bab4 commit 434fcb7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

source/module_hamilt/operator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ class Operator
9393
//create a new hpsi and delete old hpsi later
9494
T* hpsi_pointer = std::get<2>(info);
9595
const T* psi_pointer = std::get<0>(info)->get_pointer();
96+
if(this->hpsi != nullptr)
97+
{
98+
delete this->hpsi;
99+
this->hpsi = nullptr;
100+
}
96101
if(!hpsi_pointer)
97102
{
98103
ModuleBase::WARNING_QUIT("Operator::hPsi", "hpsi_pointer can not be nullptr");

0 commit comments

Comments
 (0)