From: Lars Op den Kamp Date: Mon, 16 Apr 2012 14:29:43 +0000 (+0200) Subject: cec: validate the input in CCECProcessor::IsActiveSource(). fixes potential crash... X-Git-Tag: upstream/2.2.0~1^2~31^2~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=46dfe6c479beeded3b4df937567ff93ec94cc0a8;p=deb_libcec.git cec: validate the input in CCECProcessor::IsActiveSource(). fixes potential crash when the active source isn't known. bugzid: 671 --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 204a3c4..c7d586e 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -894,7 +894,9 @@ cec_logical_address CCECProcessor::GetActiveSource(void) bool CCECProcessor::IsActiveSource(cec_logical_address iAddress) { - return m_busDevices[iAddress]->IsActiveSource(); + return iAddress > CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST ? + m_busDevices[iAddress]->IsActiveSource() : + false; } bool CCECProcessor::Transmit(const cec_command &data) @@ -1656,7 +1658,7 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration) if (IsRunning()) m_communication->PersistConfiguration(&m_configuration); - if (bReinit) + if (bReinit || m_configuration.logicalAddresses.IsEmpty()) { if (bDeviceTypeChanged) return ChangeDeviceType(oldPrimaryType, m_configuration.deviceTypes[0]);