Skip to content

Commit

Permalink
try to fix overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
CaRoLZhangxy committed Feb 27, 2024
1 parent e77f5f3 commit 7cb94ae
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions source/api_cc/src/commonPT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ void NeighborListDataPT::copy_from_nlist(const InputNlist& inlist,
memcpy(&ilist[0], inlist.ilist, inum * sizeof(int));
int* max_element = std::max_element(inlist.numneigh, inlist.numneigh + inum);
max_num_neighbors = *max_element;
unsigned long nlist_size = inum * max_num_neighbors;
unsigned long nlist_size = (unsigned long)inum * max_num_neighbors;
jlist.resize(nlist_size);
memset(&jlist[0], -1, nlist_size * sizeof(int));
for (int ii = 0; ii < inum; ++ii) {
int jnum = inlist.numneigh[ii];
numneigh[ii] = inlist.numneigh[ii];
unsigned long start_loc = ii * max_num_neighbors;
memcpy(&jlist[start_loc], inlist.firstneigh[ii], jnum * sizeof(int));
memcpy(&jlist[(unsigned long)ii * max_num_neighbors], inlist.firstneigh[ii], jnum * sizeof(int));
}
}
#endif

0 comments on commit 7cb94ae

Please sign in to comment.