From: Lars Op den Kamp Date: Fri, 13 Dec 2013 12:40:14 +0000 (+0100) Subject: fixed crash when CCECProcessor::Transmit was called after CCECProcessor::Close X-Git-Tag: upstream/2.2.0~1^2~3^2~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bb6138eabba9a42f85c3167c0a8aefbd77ff95b8;p=deb_libcec.git fixed crash when CCECProcessor::Transmit was called after CCECProcessor::Close --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 63e4815..557b76d 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -140,6 +140,7 @@ void CCECProcessor::Close(void) StopThread(); // close the connection + CLockObject lock(m_mutex); DELETE_AND_NULL(m_communication); } @@ -439,6 +440,10 @@ bool CCECProcessor::Transmit(const cec_command &data, bool bIsReply) // reset the state of this message to 'unknown' cec_adapter_message_state adapterState = ADAPTER_MESSAGE_STATE_UNKNOWN; + CLockObject lock(m_mutex); + if (!m_communication) + return false; + if (!m_communication->SupportsSourceLogicalAddress(transmitData.initiator)) { if (transmitData.initiator == CECDEVICE_UNREGISTERED && m_communication->SupportsSourceLogicalAddress(CECDEVICE_FREEUSE)) @@ -477,15 +482,14 @@ bool CCECProcessor::Transmit(const cec_command &data, bool bIsReply) } // wait until we finished allocating a new LA if it got lost + lock.Unlock(); while (m_bStallCommunication) Sleep(5); + lock.Lock(); - { - CLockObject lock(m_mutex); - m_iLastTransmission = GetTimeMs(); - // set the number of tries - iMaxTries = initiator->GetHandler()->GetTransmitRetries() + 1; - initiator->MarkHandlerReady(); - } + m_iLastTransmission = GetTimeMs(); + // set the number of tries + iMaxTries = initiator->GetHandler()->GetTransmitRetries() + 1; + initiator->MarkHandlerReady(); // and try to send the command while (bRetry && ++iTries < iMaxTries)