diff --git a/src/learner/learner-inl.hpp b/src/learner/learner-inl.hpp index b630edd4c..fc05c04c2 100644 --- a/src/learner/learner-inl.hpp +++ b/src/learner/learner-inl.hpp @@ -172,9 +172,11 @@ class BoostLearner : public rabit::ISerializable { int gap; utils::Check(fi.Read(&gap, sizeof(gap)) != 0, "BoostLearner: wrong model format"); len = len >> 32UL; - } - name_obj_.resize(len); - utils::Check(fi.Read(&name_obj_[0], len) != 0, "BoostLearner: wrong model format"); + } + if (len != 0) { + name_obj_.resize(len); + utils::Check(fi.Read(&name_obj_[0], len) != 0, "BoostLearner: wrong model format"); + } } utils::Check(fi.Read(&name_gbm_), "BoostLearner: wrong model format"); // delete existing gbm if any