cec: validate the input in CCECProcessor::IsActiveSource(). fixes potential crash...
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 16 Apr 2012 14:29:43 +0000 (16:29 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 16 Apr 2012 14:29:43 +0000 (16:29 +0200)
src/lib/CECProcessor.cpp

index 204a3c431e98672ae25abea6dd8488b0c455545f..c7d586e79cce42ab39e061a69b419ebbf786d3f6 100644 (file)
@@ -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]);