diff --git a/src/vmime/net/imap/IMAPFolder.cpp b/src/vmime/net/imap/IMAPFolder.cpp index 86f13f4b..d02e5683 100644 --- a/src/vmime/net/imap/IMAPFolder.cpp +++ b/src/vmime/net/imap/IMAPFolder.cpp @@ -767,6 +767,9 @@ void IMAPFolder::fetchMessages(std::vector >& msg, const f else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); + if (msg.empty()) + return; + // Build message numbers list std::vector list; list.reserve(msg.size()); @@ -870,6 +873,9 @@ std::vector > IMAPFolder::getAndFetchMessages else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); + if (msgs.isEmpty()) + return std::vector >(); + // Ensure we also get the UID for each message fetchAttributes attribsWithUID(attribs); attribsWithUID.add(fetchAttributes::UID); diff --git a/src/vmime/net/maildir/maildirFolder.cpp b/src/vmime/net/maildir/maildirFolder.cpp index 79f01ab8..eb0eb9fd 100644 --- a/src/vmime/net/maildir/maildirFolder.cpp +++ b/src/vmime/net/maildir/maildirFolder.cpp @@ -1187,6 +1187,9 @@ void maildirFolder::fetchMessages(std::vector >& msg, else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); + if (msg.empty()) + return; + const size_t total = msg.size(); size_t current = 0; @@ -1226,6 +1229,9 @@ void maildirFolder::fetchMessage(shared_ptr msg, const fetchAttributes std::vector > maildirFolder::getAndFetchMessages (const messageSet& msgs, const fetchAttributes& attribs) { + if (msgs.isEmpty()) + return std::vector >(); + std::vector > messages = getMessages(msgs); fetchMessages(messages, attribs); diff --git a/src/vmime/net/pop3/POP3Folder.cpp b/src/vmime/net/pop3/POP3Folder.cpp index e23030d8..78400fce 100644 --- a/src/vmime/net/pop3/POP3Folder.cpp +++ b/src/vmime/net/pop3/POP3Folder.cpp @@ -315,6 +315,9 @@ void POP3Folder::fetchMessages(std::vector >& msg, const f else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); + if (msg.empty()) + return; + const size_t total = msg.size(); size_t current = 0; @@ -487,6 +490,9 @@ void POP3Folder::fetchMessage(shared_ptr msg, const fetchAttributes& o std::vector > POP3Folder::getAndFetchMessages (const messageSet& msgs, const fetchAttributes& attribs) { + if (msgs.isEmpty()) + return std::vector >(); + std::vector > messages = getMessages(msgs); fetchMessages(messages, attribs);