Skip to content

Commit

Permalink
fix a potential problem in substr.
Browse files Browse the repository at this point in the history
  • Loading branch information
guolinke committed Dec 25, 2017
1 parent 72f2349 commit e757300
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/boosting/gbdt_model_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,10 @@ bool GBDT::LoadModelFromString(const char* buffer, size_t len) {
}
else if (strs.size() > 2) {
if (strs[0] == "feature_name") {
key_vals[strs[0]] = cur_line.substr(std::strlen("feature_names=")).c_str();
key_vals[strs[0]] = cur_line.substr(std::strlen("feature_names="));
} else {
Log::Fatal("Wrong line at model file: %s", cur_line.substr(0, 128).c_str());
// Use first 128 chars to avoid exceed the message buffer.
Log::Fatal("Wrong line at model file: %s", cur_line.substr(0, std::min<size_t>(128, cur_line.size())).c_str());
}
}
}
Expand Down

0 comments on commit e757300

Please sign in to comment.