Commit e757300f authored by Guolin Ke's avatar Guolin Ke
Browse files

fix a potential problem in substr.

parent 72f2349a
......@@ -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());
}
}
}
......
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