diff options
author | Vincent Richard <[email protected]> | 2009-12-08 10:03:34 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2009-12-08 10:03:34 +0000 |
commit | a3bf37fb4f758469b7b68ad7dcca170913fcd912 (patch) | |
tree | 9004b6aca2e4e749212f959011417d52f21c5cb9 /src | |
parent | Initialize multi-threading for GNUTLS/GCrypt (thanks to Bartek Szurgot). (diff) | |
download | vmime-a3bf37fb4f758469b7b68ad7dcca170913fcd912.tar.gz vmime-a3bf37fb4f758469b7b68ad7dcca170913fcd912.zip |
Fixed not exception-safe constructor, which could lead to possible memory leak (thanks to Bartek Szurgot). Get rid of const-ness on factories.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/maildir/format/courierMaildirFormat.cpp | 12 | ||||
-rw-r--r-- | src/net/maildir/format/kmailMaildirFormat.cpp | 12 | ||||
-rw-r--r-- | src/net/maildir/maildirFolder.cpp | 12 | ||||
-rw-r--r-- | src/net/maildir/maildirMessage.cpp | 6 | ||||
-rw-r--r-- | src/net/maildir/maildirStore.cpp | 2 | ||||
-rw-r--r-- | src/platforms/posix/posixHandler.cpp | 20 | ||||
-rw-r--r-- | src/platforms/windows/windowsHandler.cpp | 16 |
7 files changed, 36 insertions, 44 deletions
diff --git a/src/net/maildir/format/courierMaildirFormat.cpp b/src/net/maildir/format/courierMaildirFormat.cpp index 6dbda80b..721517e8 100644 --- a/src/net/maildir/format/courierMaildirFormat.cpp +++ b/src/net/maildir/format/courierMaildirFormat.cpp @@ -49,7 +49,7 @@ const string courierMaildirFormat::getName() const void courierMaildirFormat::createFolder(const folder::path& path) { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY))) throw exceptions::invalid_folder_name(); @@ -80,7 +80,7 @@ void courierMaildirFormat::createFolder(const folder::path& path) void courierMaildirFormat::destroyFolder(const folder::path& path) { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); // Recursively delete directories of subfolders const std::vector <folder::path> folders = listFolders(path, true); @@ -119,7 +119,7 @@ void courierMaildirFormat::renameFolder void courierMaildirFormat::renameFolderImpl (const folder::path& oldPath, const folder::path& newPath) { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path oldFSPath = folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY); @@ -134,7 +134,7 @@ void courierMaildirFormat::renameFolderImpl bool courierMaildirFormat::folderExists(const folder::path& path) const { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); ref <utility::file> rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); @@ -254,7 +254,7 @@ const std::vector <folder::path> courierMaildirFormat::listFolders bool courierMaildirFormat::listDirectories(const folder::path& root, std::vector <string>& dirs, const bool onlyTestForExistence) const { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); ref <utility::file> rootDir = fsf->create (getContext()->getStore()->getFileSystemPath()); @@ -496,7 +496,7 @@ const folder::path::component courierMaildirFormat::fromModifiedUTF7(const strin bool courierMaildirFormat::supports() const { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); ref <utility::file> rootDir = fsf->create (getContext()->getStore()->getFileSystemPath()); diff --git a/src/net/maildir/format/kmailMaildirFormat.cpp b/src/net/maildir/format/kmailMaildirFormat.cpp index 5fb75feb..a21d1061 100644 --- a/src/net/maildir/format/kmailMaildirFormat.cpp +++ b/src/net/maildir/format/kmailMaildirFormat.cpp @@ -49,7 +49,7 @@ const string kmailMaildirFormat::getName() const void kmailMaildirFormat::createFolder(const folder::path& path) { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY))) throw exceptions::invalid_folder_name(); @@ -75,7 +75,7 @@ void kmailMaildirFormat::createFolder(const folder::path& path) void kmailMaildirFormat::destroyFolder(const folder::path& path) { // Delete 'folder' and '.folder.directory' directories - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); maildirUtils::recursiveFSDelete(fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY))); // root @@ -87,7 +87,7 @@ void kmailMaildirFormat::destroyFolder(const folder::path& path) bool kmailMaildirFormat::folderExists(const folder::path& path) const { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); ref <utility::file> rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); @@ -177,7 +177,7 @@ const std::vector <folder::path> kmailMaildirFormat::listFolders void kmailMaildirFormat::listFoldersImpl (std::vector <folder::path>& list, const folder::path& root, const bool recursive) const { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); ref <utility::file> rootDir = fsf->create(folderPathToFileSystemPath(root, root.isEmpty() ? ROOT_DIRECTORY : CONTAINER_DIRECTORY)); @@ -226,7 +226,7 @@ bool kmailMaildirFormat::isSubfolderDirectory(const utility::file& file) void kmailMaildirFormat::renameFolder(const folder::path& oldPath, const folder::path& newPath) { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); ref <utility::file> rootDir = fsf->create (folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY)); @@ -277,7 +277,7 @@ void kmailMaildirFormat::renameFolder(const folder::path& oldPath, const folder: bool kmailMaildirFormat::folderHasSubfolders(const folder::path& path) const { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); ref <utility::file> rootDir = fsf->create (folderPathToFileSystemPath(path, CONTAINER_DIRECTORY)); diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp index 3e361ae1..dd680c9c 100644 --- a/src/net/maildir/maildirFolder.cpp +++ b/src/net/maildir/maildirFolder.cpp @@ -264,7 +264,7 @@ void maildirFolder::scanFolder() m_messageCount = 0; m_unreadMessageCount = 0; - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path newDirPath = store->getFormat()->folderPathToFileSystemPath (m_path, maildirFormat::NEW_DIRECTORY); @@ -760,7 +760,7 @@ void maildirFolder::setMessageFlagsImpl { ref <maildirStore> store = m_store.acquire(); - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path curDirPath = store->getFormat()-> folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY); @@ -832,7 +832,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size, else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path tmpDirPath = store->getFormat()-> folderPathToFileSystemPath(m_path,maildirFormat::TMP_DIRECTORY); @@ -918,7 +918,7 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress) { - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); ref <utility::file> file = fsf->create(tmpDirPath / filename); @@ -1058,7 +1058,7 @@ void maildirFolder::copyMessagesImpl(const folder::path& dest, const std::vector { ref <maildirStore> store = m_store.acquire(); - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath (m_path, maildirFormat::CUR_DIRECTORY); @@ -1200,7 +1200,7 @@ void maildirFolder::expunge() else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path curDirPath = store->getFormat()-> folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY); diff --git a/src/net/maildir/maildirMessage.cpp b/src/net/maildir/maildirMessage.cpp index ed87cdb3..8999d847 100644 --- a/src/net/maildir/maildirMessage.cpp +++ b/src/net/maildir/maildirMessage.cpp @@ -346,7 +346,7 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis { ref <const maildirFolder> folder = m_folder.acquire(); - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); ref <utility::file> file = fsf->create(path); @@ -393,7 +393,7 @@ void maildirMessage::fetchPartHeader(ref <part> p) ref <maildirPart> mp = p.dynamicCast <maildirPart>(); - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); ref <utility::file> file = fsf->create(path); @@ -430,7 +430,7 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const int options) if (folder != msgFolder) throw exceptions::folder_not_found(); - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); ref <utility::file> file = fsf->create(path); diff --git a/src/net/maildir/maildirStore.cpp b/src/net/maildir/maildirStore.cpp index 3b770246..26f4593a 100644 --- a/src/net/maildir/maildirStore.cpp +++ b/src/net/maildir/maildirStore.cpp @@ -132,7 +132,7 @@ void maildirStore::connect() throw exceptions::already_connected(); // Get root directory - utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory(); + ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); m_fsPath = fsf->stringToPath(GET_PROPERTY(string, PROPERTY_SERVER_ROOTPATH)); diff --git a/src/platforms/posix/posixHandler.cpp b/src/platforms/posix/posixHandler.cpp index f43972ee..104bc404 100644 --- a/src/platforms/posix/posixHandler.cpp +++ b/src/platforms/posix/posixHandler.cpp @@ -55,18 +55,14 @@ posixHandler::posixHandler() m_socketFactory = vmime::create <posixSocketFactory>(); #endif #if VMIME_HAVE_FILESYSTEM_FEATURES - m_fileSysFactory = new posixFileSystemFactory(); - m_childProcFactory = new posixChildProcessFactory(); + m_fileSysFactory = vmime::create <posixFileSystemFactory>(); + m_childProcFactory = vmime::create <posixChildProcessFactory>(); #endif } posixHandler::~posixHandler() { -#if VMIME_HAVE_FILESYSTEM_FEATURES - delete (m_fileSysFactory); - delete (m_childProcFactory); -#endif } @@ -173,9 +169,9 @@ unsigned int posixHandler::getProcessId() const #if VMIME_HAVE_MESSAGING_FEATURES -ref <vmime::net::socketFactory> posixHandler::getSocketFactory() const +ref <vmime::net::socketFactory> posixHandler::getSocketFactory() { - return m_socketFactory.dynamicCast <vmime::net::socketFactory>(); + return m_socketFactory; } #endif @@ -183,15 +179,15 @@ ref <vmime::net::socketFactory> posixHandler::getSocketFactory() const #if VMIME_HAVE_FILESYSTEM_FEATURES -vmime::utility::fileSystemFactory* posixHandler::getFileSystemFactory() const +ref <vmime::utility::fileSystemFactory> posixHandler::getFileSystemFactory() { - return (m_fileSysFactory); + return m_fileSysFactory; } -vmime::utility::childProcessFactory* posixHandler::getChildProcessFactory() const +ref <vmime::utility::childProcessFactory> posixHandler::getChildProcessFactory() { - return (m_childProcFactory); + return m_childProcFactory; } #endif diff --git a/src/platforms/windows/windowsHandler.cpp b/src/platforms/windows/windowsHandler.cpp index 404d3cbc..1a37c839 100644 --- a/src/platforms/windows/windowsHandler.cpp +++ b/src/platforms/windows/windowsHandler.cpp @@ -49,17 +49,13 @@ windowsHandler::windowsHandler() m_socketFactory = vmime::create <windowsSocketFactory>(); #endif #if VMIME_HAVE_FILESYSTEM_FEATURES - m_fileSysFactory = new windowsFileSystemFactory(); + m_fileSysFactory = vmime::create <windowsFileSystemFactory>(); #endif } windowsHandler::~windowsHandler() { -#if VMIME_HAVE_FILESYSTEM_FEATURES - delete (m_fileSysFactory); -#endif - WSACleanup(); } @@ -240,9 +236,9 @@ unsigned int windowsHandler::getProcessId() const #if VMIME_HAVE_MESSAGING_FEATURES -ref <vmime::net::socketFactory> windowsHandler::getSocketFactory() const +ref <vmime::net::socketFactory> windowsHandler::getSocketFactory() { - return m_socketFactory.dynamicCast <vmime::net::socketFactory>(); + return m_socketFactory; } #endif @@ -250,13 +246,13 @@ ref <vmime::net::socketFactory> windowsHandler::getSocketFactory() const #if VMIME_HAVE_FILESYSTEM_FEATURES -vmime::utility::fileSystemFactory* windowsHandler::getFileSystemFactory() const +ref <vmime::utility::fileSystemFactory> windowsHandler::getFileSystemFactory() { - return (m_fileSysFactory); + return m_fileSysFactory; } -vmime::utility::childProcessFactory* windowsHandler::getChildProcessFactory() const +ref <vmime::utility::childProcessFactory> windowsHandler::getChildProcessFactory() { // TODO: Not implemented return (NULL); |