Skip to content

Commit c04b8c9

Browse files
authored
Fix: array overreach in psi2rho of uspp (#3961)
1 parent 91815db commit c04b8c9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

source/module_elecstate/elecstate_pw.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void ElecStatePW<T, Device>::init_rho_data()
6969
}
7070
}
7171
resmem_complex_op()(this->ctx, this->wfcr, this->basis->nmaxgr, "ElecSPW::wfcr");
72-
resmem_complex_op()(this->ctx, this->wfcr_another_spin, this->charge->nrxx, "ElecSPW::wfcr_a");
72+
resmem_complex_op()(this->ctx, this->wfcr_another_spin, this->basis->nrxx, "ElecSPW::wfcr_a");
7373
this->init_rho = true;
7474
}
7575

@@ -184,7 +184,14 @@ void ElecStatePW<T, Device>::rhoBandK(const psi::Psi<T, Device>& psi)
184184
if (w1 != 0.0)
185185
{
186186
// replaced by denghui at 20221110
187-
elecstate_pw_op()(this->ctx, GlobalV::DOMAG, GlobalV::DOMAG_Z, this->charge->nrxx, w1, this->rho, this->wfcr, this->wfcr_another_spin);
187+
elecstate_pw_op()(this->ctx,
188+
GlobalV::DOMAG,
189+
GlobalV::DOMAG_Z,
190+
this->basis->nrxx,
191+
w1,
192+
this->rho,
193+
this->wfcr,
194+
this->wfcr_another_spin);
188195
}
189196
}
190197
}
@@ -203,7 +210,7 @@ void ElecStatePW<T, Device>::rhoBandK(const psi::Psi<T, Device>& psi)
203210
if (w1 != 0.0)
204211
{
205212
// replaced by denghui at 20221110
206-
elecstate_pw_op()(this->ctx, current_spin, this->charge->nrxx, w1, this->rho, this->wfcr);
213+
elecstate_pw_op()(this->ctx, current_spin, this->basis->nrxx, w1, this->rho, this->wfcr);
207214
}
208215

209216
// kinetic energy density

0 commit comments

Comments
 (0)