cec: check whether m_port isn't NULL in ReadFromDevice
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 4 Oct 2011 18:59:47 +0000 (20:59 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 4 Oct 2011 18:59:47 +0000 (20:59 +0200)
src/lib/AdapterCommunication.cpp

index be9485824be8e2f7dd30f6c29047428a8f370f2d..d56ee168b642df7d2ab173677569c0271222ecdb 100644 (file)
@@ -116,8 +116,6 @@ void *CAdapterCommunication::Process(void)
       CCondition::Sleep(50);
   }
 
-  m_controller->AddLog(CEC_LOG_DEBUG, "reader thread terminated");
-
   CLockObject lock(&m_commMutex);
   m_bStarted = false;
   return NULL;
@@ -127,6 +125,9 @@ bool CAdapterCommunication::ReadFromDevice(int iTimeout)
 {
   uint8_t buff[1024];
   CLockObject lock(&m_commMutex);
+  if (!m_port)
+    return false;
+
   int iBytesRead = m_port->Read(buff, sizeof(buff), iTimeout);
   lock.Leave();
   if (iBytesRead < 0)