Unverified Commit 13ed38ca authored by david-cortes's avatar david-cortes Committed by GitHub
Browse files

Fix ASAN issues with `std::function` usage (#4673)

* don't compare std::function to nullptr ref #4633

* Update dataset_loader.h
parent fddff1ad
...@@ -67,7 +67,7 @@ class DatasetLoader { ...@@ -67,7 +67,7 @@ class DatasetLoader {
/*! \brief Random generator*/ /*! \brief Random generator*/
Random random_; Random random_;
/*! \brief prediction function for initial model */ /*! \brief prediction function for initial model */
const PredictFunction& predict_fun_; const PredictFunction predict_fun_;
/*! \brief number of classes */ /*! \brief number of classes */
int num_class_; int num_class_;
/*! \brief index of label column */ /*! \brief index of label column */
......
...@@ -1143,7 +1143,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector<std::string>* text_dat ...@@ -1143,7 +1143,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector<std::string>* text_dat
double tmp_label = 0.0f; double tmp_label = 0.0f;
auto& ref_text_data = *text_data; auto& ref_text_data = *text_data;
std::vector<float> feature_row(dataset->num_features_); std::vector<float> feature_row(dataset->num_features_);
if (predict_fun_ == nullptr) { if (!predict_fun_) {
OMP_INIT_EX(); OMP_INIT_EX();
// if doesn't need to prediction with initial model // if doesn't need to prediction with initial model
#pragma omp parallel for schedule(static) private(oneline_features) firstprivate(tmp_label, feature_row) #pragma omp parallel for schedule(static) private(oneline_features) firstprivate(tmp_label, feature_row)
...@@ -1262,7 +1262,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector<std::string>* text_dat ...@@ -1262,7 +1262,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector<std::string>* text_dat
void DatasetLoader::ExtractFeaturesFromFile(const char* filename, const Parser* parser, void DatasetLoader::ExtractFeaturesFromFile(const char* filename, const Parser* parser,
const std::vector<data_size_t>& used_data_indices, Dataset* dataset) { const std::vector<data_size_t>& used_data_indices, Dataset* dataset) {
std::vector<double> init_score; std::vector<double> init_score;
if (predict_fun_ != nullptr) { if (predict_fun_) {
init_score = std::vector<double>(dataset->num_data_ * num_class_); init_score = std::vector<double>(dataset->num_data_ * num_class_);
} }
std::function<void(data_size_t, const std::vector<std::string>&)> process_fun = std::function<void(data_size_t, const std::vector<std::string>&)> process_fun =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment