Skip to content

Commit

Permalink
Bounds checking of used_row_indices (#959) (#969)
Browse files Browse the repository at this point in the history
* Bounds checking of used_row_indices (#959)

* add Common::check_int32_elements_interval_closed function.

* insert a bounds checking code in LGBM_DatasetGetSubset function of C API.

* Delete a needless function

* delete the function check_int32_elements_interval_closed
  • Loading branch information
Tony-Y authored and guolinke committed Oct 8, 2017
1 parent 87fa8b5 commit b377f48
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@ int LGBM_DatasetGetSubset(
}
auto full_dataset = reinterpret_cast<const Dataset*>(handle);
CHECK(num_used_row_indices > 0);
const int32_t lower = 0;
const int32_t upper = full_dataset->num_data() - 1;
Common::CheckElementsIntervalClosed(used_row_indices, lower, upper, num_used_row_indices, "Used indices of subset");
auto ret = std::unique_ptr<Dataset>(new Dataset(num_used_row_indices));
ret->CopyFeatureMapperFrom(full_dataset);
ret->CopySubset(full_dataset, used_row_indices, num_used_row_indices, true);
Expand Down

0 comments on commit b377f48

Please sign in to comment.