Commit 5b248341 authored by Guolin Ke's avatar Guolin Ke
Browse files

avoid the bad_alloc when overflow.

parent cdba7147
...@@ -615,6 +615,7 @@ Dataset* DatasetLoader::CostructFromSampleData(double** sample_values, ...@@ -615,6 +615,7 @@ Dataset* DatasetLoader::CostructFromSampleData(double** sample_values,
int type_size = BinMapper::SizeForSpecificBin(max_bin); int type_size = BinMapper::SizeForSpecificBin(max_bin);
// since sizes of different feature may not be same, we expand all bin mapper to type_size // since sizes of different feature may not be same, we expand all bin mapper to type_size
comm_size_t buffer_size = type_size * total_num_feature; comm_size_t buffer_size = type_size * total_num_feature;
CHECK(buffer_size >= 0);
auto input_buffer = std::vector<char>(buffer_size); auto input_buffer = std::vector<char>(buffer_size);
auto output_buffer = std::vector<char>(buffer_size); auto output_buffer = std::vector<char>(buffer_size);
...@@ -917,6 +918,7 @@ void DatasetLoader::ConstructBinMappersFromTextData(int rank, int num_machines, ...@@ -917,6 +918,7 @@ void DatasetLoader::ConstructBinMappersFromTextData(int rank, int num_machines,
int type_size = BinMapper::SizeForSpecificBin(max_bin); int type_size = BinMapper::SizeForSpecificBin(max_bin);
// since sizes of different feature may not be same, we expand all bin mapper to type_size // since sizes of different feature may not be same, we expand all bin mapper to type_size
comm_size_t buffer_size = type_size * num_total_features; comm_size_t buffer_size = type_size * num_total_features;
CHECK(buffer_size >= 0);
auto input_buffer = std::vector<char>(buffer_size); auto input_buffer = std::vector<char>(buffer_size);
auto output_buffer = std::vector<char>(buffer_size); auto output_buffer = std::vector<char>(buffer_size);
......
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