Skip to content

Commit

Permalink
Fix: array overreach in psi2rho of uspp (#3961)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuLiu98 committed Apr 12, 2024
1 parent 91815db commit c04b8c9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions source/module_elecstate/elecstate_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void ElecStatePW<T, Device>::init_rho_data()
}
}
resmem_complex_op()(this->ctx, this->wfcr, this->basis->nmaxgr, "ElecSPW::wfcr");
resmem_complex_op()(this->ctx, this->wfcr_another_spin, this->charge->nrxx, "ElecSPW::wfcr_a");
resmem_complex_op()(this->ctx, this->wfcr_another_spin, this->basis->nrxx, "ElecSPW::wfcr_a");
this->init_rho = true;
}

Expand Down Expand Up @@ -184,7 +184,14 @@ void ElecStatePW<T, Device>::rhoBandK(const psi::Psi<T, Device>& psi)
if (w1 != 0.0)
{
// replaced by denghui at 20221110
elecstate_pw_op()(this->ctx, GlobalV::DOMAG, GlobalV::DOMAG_Z, this->charge->nrxx, w1, this->rho, this->wfcr, this->wfcr_another_spin);
elecstate_pw_op()(this->ctx,
GlobalV::DOMAG,
GlobalV::DOMAG_Z,
this->basis->nrxx,
w1,
this->rho,
this->wfcr,
this->wfcr_another_spin);
}
}
}
Expand All @@ -203,7 +210,7 @@ void ElecStatePW<T, Device>::rhoBandK(const psi::Psi<T, Device>& psi)
if (w1 != 0.0)
{
// replaced by denghui at 20221110
elecstate_pw_op()(this->ctx, current_spin, this->charge->nrxx, w1, this->rho, this->wfcr);
elecstate_pw_op()(this->ctx, current_spin, this->basis->nrxx, w1, this->rho, this->wfcr);
}

// kinetic energy density
Expand Down

0 comments on commit c04b8c9

Please sign in to comment.