From a3bf37fb4f758469b7b68ad7dcca170913fcd912 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Tue, 8 Dec 2009 10:03:34 +0000 Subject: Fixed not exception-safe constructor, which could lead to possible memory leak (thanks to Bartek Szurgot). Get rid of const-ness on factories. --- src/platforms/posix/posixHandler.cpp | 20 ++++++++------------ src/platforms/windows/windowsHandler.cpp | 16 ++++++---------- 2 files changed, 14 insertions(+), 22 deletions(-) (limited to 'src/platforms') 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 (); #endif #if VMIME_HAVE_FILESYSTEM_FEATURES - m_fileSysFactory = new posixFileSystemFactory(); - m_childProcFactory = new posixChildProcessFactory(); + m_fileSysFactory = vmime::create (); + m_childProcFactory = vmime::create (); #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 posixHandler::getSocketFactory() const +ref posixHandler::getSocketFactory() { - return m_socketFactory.dynamicCast (); + return m_socketFactory; } #endif @@ -183,15 +179,15 @@ ref posixHandler::getSocketFactory() const #if VMIME_HAVE_FILESYSTEM_FEATURES -vmime::utility::fileSystemFactory* posixHandler::getFileSystemFactory() const +ref posixHandler::getFileSystemFactory() { - return (m_fileSysFactory); + return m_fileSysFactory; } -vmime::utility::childProcessFactory* posixHandler::getChildProcessFactory() const +ref 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 (); #endif #if VMIME_HAVE_FILESYSTEM_FEATURES - m_fileSysFactory = new windowsFileSystemFactory(); + m_fileSysFactory = vmime::create (); #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 windowsHandler::getSocketFactory() const +ref windowsHandler::getSocketFactory() { - return m_socketFactory.dynamicCast (); + return m_socketFactory; } #endif @@ -250,13 +246,13 @@ ref windowsHandler::getSocketFactory() const #if VMIME_HAVE_FILESYSTEM_FEATURES -vmime::utility::fileSystemFactory* windowsHandler::getFileSystemFactory() const +ref windowsHandler::getFileSystemFactory() { - return (m_fileSysFactory); + return m_fileSysFactory; } -vmime::utility::childProcessFactory* windowsHandler::getChildProcessFactory() const +ref windowsHandler::getChildProcessFactory() { // TODO: Not implemented return (NULL); -- cgit