Skip to content

Commit

Permalink
[core] fix out-of-bounds access when symmetrizing in builder.h
Browse files Browse the repository at this point in the history
This bug reaches out of max bound of invs_needed and adds an unpredictable value to total_missing_inv
  • Loading branch information
4cce8er authored and sbeamer committed Oct 2, 2023
1 parent 403fc77 commit 24261d2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,11 @@ class BuilderBase {
}
// increase offsets to account for missing inverses, realloc neighs
SGOffset total_missing_inv = 0;
for (NodeID_ n = 0; n <= num_nodes_; n++) {
for (NodeID_ n = 0; n < num_nodes_; n++) {
offsets[n] += total_missing_inv;
total_missing_inv += invs_needed[n];
}
offsets[num_nodes_] += total_missing_inv;
size_t newsize = (offsets[num_nodes_] * sizeof(DestID_));
*neighs = static_cast<DestID_*>(std::realloc(*neighs, newsize));
if (*neighs == nullptr) {
Expand Down

0 comments on commit 24261d2

Please sign in to comment.