Skip to content

Commit

Permalink
Fix ASAN issues with std::function usage (#4673)
Browse files Browse the repository at this point in the history
* don't compare std::function to nullptr ref #4633

* Update dataset_loader.h
  • Loading branch information
david-cortes authored Oct 20, 2021
1 parent fddff1a commit 13ed38c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/LightGBM/dataset_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class DatasetLoader {
/*! \brief Random generator*/
Random random_;
/*! \brief prediction function for initial model */
const PredictFunction& predict_fun_;
const PredictFunction predict_fun_;
/*! \brief number of classes */
int num_class_;
/*! \brief index of label column */
Expand Down
4 changes: 2 additions & 2 deletions src/io/dataset_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector<std::string>* text_dat
double tmp_label = 0.0f;
auto& ref_text_data = *text_data;
std::vector<float> feature_row(dataset->num_features_);
if (predict_fun_ == nullptr) {
if (!predict_fun_) {
OMP_INIT_EX();
// if doesn't need to prediction with initial model
#pragma omp parallel for schedule(static) private(oneline_features) firstprivate(tmp_label, feature_row)
Expand Down Expand Up @@ -1262,7 +1262,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector<std::string>* text_dat
void DatasetLoader::ExtractFeaturesFromFile(const char* filename, const Parser* parser,
const std::vector<data_size_t>& used_data_indices, Dataset* dataset) {
std::vector<double> init_score;
if (predict_fun_ != nullptr) {
if (predict_fun_) {
init_score = std::vector<double>(dataset->num_data_ * num_class_);
}
std::function<void(data_size_t, const std::vector<std::string>&)> process_fun =
Expand Down

0 comments on commit 13ed38c

Please sign in to comment.