Skip to content

Commit

Permalink
Merge pull request #398 from jamesjer/master
Browse files Browse the repository at this point in the history
Fix out-of-bounds vector accesses in Pruner::enforce.
  • Loading branch information
shi-bai committed Dec 14, 2019
2 parents f7eedb6 + f68e257 commit 7d696e9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fplll/pruner/pruner.h
Expand Up @@ -1027,8 +1027,8 @@ template <class FT> inline bool Pruner<FT>::enforce(/*io*/ vec &b, /*opt i*/ con
status |= (b[i] > 1.0001);
b[i] = b[i] > 1 ? 1. : b[i];

// note min_pruning_coefficients always has length n
if (b[i] <= min_pruning_coefficients[i / c])
// note min_pruning_coefficients always has length d
if (i / c < d && b[i] <= min_pruning_coefficients[i / c])
b[i] = min_pruning_coefficients[i / c];
}

Expand All @@ -1041,7 +1041,7 @@ template <class FT> inline bool Pruner<FT>::enforce(/*io*/ vec &b, /*opt i*/ con
}
}

for (int i = j - 1; i >= 0; --i)
for (int i = std::min(j - 1, dn - 2); i >= 0; --i)
{
if (b[i + 1] < b[i])
{
Expand Down

0 comments on commit 7d696e9

Please sign in to comment.