Skip to content

Commit

Permalink
Upcast index to size_t in Refit (closes #3227) (#3228)
Browse files Browse the repository at this point in the history
In the current implementation, the index is an int32, which will segfault with large data sets and a large number of estimators.
  • Loading branch information
jtilly authored Jul 16, 2020
1 parent fc79b36 commit f5f27ca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class Booster {
std::vector<std::vector<int32_t>> v_leaf_preds(nrow, std::vector<int32_t>(ncol, 0));
for (int i = 0; i < nrow; ++i) {
for (int j = 0; j < ncol; ++j) {
v_leaf_preds[i][j] = leaf_preds[i * ncol + j];
v_leaf_preds[i][j] = leaf_preds[static_cast<size_t>(i) * static_cast<size_t>(ncol) + static_cast<size_t>(j)];
}
}
boosting_->RefitTree(v_leaf_preds);
Expand Down

0 comments on commit f5f27ca

Please sign in to comment.