diff --git a/libcorpus2_whole/corpus.h b/libcorpus2_whole/corpus.h index 3f1a55e8d12166432f1d03ee2144fd9cb4a272b6..d00a3261a0cee22e66f433614d94420ce1005a78 100644 --- a/libcorpus2_whole/corpus.h +++ b/libcorpus2_whole/corpus.h @@ -51,9 +51,14 @@ public: /// Next document in corpus boost::shared_ptr<Document> next_document() { if (!this->set_) { - this->set_ = true; - this->current_document_ = documents_.begin(); - + if (this->documents_.size() == 0) { + boost::shared_ptr<Document> tmp; + return tmp; + } + else { + this->set_ = true; + this->current_document_ = documents_.begin(); + } } else { current_document_++;