Skip to content

Commit

Permalink
Merge pull request #1 from Legrandgroup/fix-nullptr-dereference
Browse files Browse the repository at this point in the history
Fixing potential NULL pointer dereference
  • Loading branch information
Nicolas Gillen authored Mar 15, 2019
2 parents 3ac8468 + 103ec88 commit 5f1202b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/spi/serial/SerialUartDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

SerialUartDriver::SerialUartDriver() :
m_serial_port(),
m_data_input_observable(),
m_data_input_observable(nullptr),
m_read_thread_alive(false),
m_read_messages_thread() { }

Expand Down Expand Up @@ -60,7 +60,8 @@ int SerialUartDriver::open(const std::string& serialPortName, unsigned int baudR
while (this->m_read_thread_alive) {
try {
rdcnt = this->m_serial_port.read(readData, sizeof(readData)/sizeof(unsigned char));
this->m_data_input_observable->notifyObservers(readData, rdcnt);
if (this->m_data_input_observable)
this->m_data_input_observable->notifyObservers(readData, rdcnt);
}
catch (std::exception& e) {
clogE << "Exception in read thread: " << e.what() << "\n";
Expand Down

0 comments on commit 5f1202b

Please sign in to comment.