From 74955c877fabef965a7d902b528fa8fff3ca6851 Mon Sep 17 00:00:00 2001 From: sijchen Date: Tue, 16 Feb 2016 12:17:21 -0800 Subject: [PATCH] set pointers to null and call uninit --- codec/common/src/WelsThreadPool.cpp | 17 +++++++++++++++++ codec/encoder/core/src/wels_task_management.cpp | 1 + 2 files changed, 18 insertions(+) diff --git a/codec/common/src/WelsThreadPool.cpp b/codec/common/src/WelsThreadPool.cpp index 904b52f1..f0135694 100644 --- a/codec/common/src/WelsThreadPool.cpp +++ b/codec/common/src/WelsThreadPool.cpp @@ -52,16 +52,28 @@ CWelsThreadPool::CWelsThreadPool (IWelsThreadPoolSink* pSink, int32_t iMaxThread if (NULL == m_cWaitedTasks || NULL == m_cIdleThreads || NULL == m_cBusyThreads) { delete m_cWaitedTasks; + m_cWaitedTasks = NULL; + delete m_cIdleThreads; + m_cIdleThreads = NULL; + delete m_cBusyThreads; + m_cBusyThreads = NULL; + return; } if (WELS_THREAD_ERROR_OK != Init (iMaxThreadNum)) { Uninit(); + delete m_cWaitedTasks; + m_cWaitedTasks = NULL; + delete m_cIdleThreads; + m_cIdleThreads = NULL; + delete m_cBusyThreads; + m_cBusyThreads = NULL; } } @@ -70,8 +82,13 @@ CWelsThreadPool::~CWelsThreadPool() { Uninit(); delete m_cWaitedTasks; + m_cWaitedTasks = NULL; + delete m_cIdleThreads; + m_cIdleThreads = NULL; + delete m_cBusyThreads; + m_cBusyThreads = NULL; } WELS_THREAD_ERROR_CODE CWelsThreadPool::OnTaskStart (CWelsTaskThread* pThread, IWelsTask* pTask) { diff --git a/codec/encoder/core/src/wels_task_management.cpp b/codec/encoder/core/src/wels_task_management.cpp index 0540c3a2..89d0cbc6 100644 --- a/codec/encoder/core/src/wels_task_management.cpp +++ b/codec/encoder/core/src/wels_task_management.cpp @@ -66,6 +66,7 @@ IWelsTaskManage* IWelsTaskManage::CreateTaskManage (sWelsEncCtx* pCtx, const i WELS_VERIFY_RETURN_IF (NULL, NULL == pTaskManage) if ( ENC_RETURN_SUCCESS != pTaskManage->Init (pCtx) ) { + pTaskManage->Uninit(); delete pTaskManage; pTaskManage = NULL; }