From 2617f376c3e04730596e81ce2fd26c9a6481dcd8 Mon Sep 17 00:00:00 2001 From: maki49 <1579492865@qq.com> Date: Fri, 18 Oct 2024 17:00:59 +0800 Subject: [PATCH] fix a segfault in rhog_symmetry --- source/module_cell/module_symmetry/symmetry.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/module_cell/module_symmetry/symmetry.cpp b/source/module_cell/module_symmetry/symmetry.cpp index 4cc925fedb..2ae95436cb 100644 --- a/source/module_cell/module_symmetry/symmetry.cpp +++ b/source/module_cell/module_symmetry/symmetry.cpp @@ -1560,8 +1560,8 @@ void Symmetry::rhog_symmetry(std::complex *rhogtot, assert(nrotk <=48 ); //map the gmatrix to inv - int* invmap = new int[nrotk]; - this->gmatrix_invmap(kgmatrix, nrotk, invmap); + std::vectorinvmap(this->nrotk, -1); + this->gmatrix_invmap(kgmatrix, nrotk, invmap.data()); // --------------------------------------------------- /* This code defines a lambda function called "rotate_recip" that takes @@ -1629,6 +1629,7 @@ ModuleBase::timer::tick("Symmetry","group fft grids"); int rot_count=0; for (int isym = 0; isym < nrotk; ++isym) { + if (invmap[isym] < 0 || invmap[isym] > nrotk) { continue; } //tmp variables int ii, jj, kk=0; rotate_recip(kgmatrix[invmap[isym]], tmp_gdirect0, ii, jj, kk); @@ -1750,7 +1751,6 @@ for (int g_index = 0; g_index < group_index; g_index++) delete[] symflag; delete[] isymflag; delete[] table_xyz; - delete[] invmap; delete[] count_xyz; ModuleBase::timer::tick("Symmetry","rhog_symmetry"); }