Skip to content
Permalink
Browse files

Merge pull request #1344 from ijaureguiberry/master

Fix valgrind memory warnings and potential cause for a segmentation fault.
  • Loading branch information...
Fishwaldo committed Dec 4, 2017
2 parents 1f7bed7 + 6dbbf6b commit a46f3f36271f88eed5aea58899a6cb118ad312a2
Showing with 10 additions and 2 deletions.
  1. +4 −1 cpp/src/Driver.cpp
  2. +3 −0 cpp/src/Msg.cpp
  3. +3 −1 cpp/src/platform/Stream.cpp
@@ -201,6 +201,8 @@ m_nondelivery( 0 ),
m_routedbusy( 0 ),
m_broadcastReadCnt( 0 ),
m_broadcastWriteCnt( 0 ),
AuthKey( 0 ),
EncryptKey( 0 ),
m_nonceReportSent( 0 ),
m_nonceReportSentAttempt( 0 )
{
@@ -352,7 +354,8 @@ Driver::~Driver

m_notificationsEvent->Release();
m_nodeMutex->Release();

delete AuthKey;
delete EncryptKey;
}

//-----------------------------------------------------------------------------
@@ -81,6 +81,9 @@ Msg::Msg
m_expectedReply = _expectedReply ? _expectedReply : _function;
}

memset(m_buffer, 0x00, 256);
memset(e_buffer, 0x00, 256);

m_buffer[0] = SOF;
m_buffer[1] = 0; // Length of the following data, filled in during Finalize.
m_buffer[2] = _msgType;
@@ -51,6 +51,7 @@ Stream::Stream
m_mutex( new Mutex() )
{
m_buffer = new uint8[m_bufferSize];
memset(m_buffer, 0x00, m_bufferSize);
}

//-----------------------------------------------------------------------------
@@ -150,8 +151,9 @@ bool Stream::Put

memcpy( &m_buffer[m_head], _buffer, block1 );
memcpy( m_buffer, &_buffer[block1], block2 );
uint8 * logpos = m_buffer + m_head;
m_head = block2;
LogData( m_buffer + m_head - block1, block1, " Read (controller->buffer): ");
LogData( logpos, block1, " Read (controller->buffer): ");
LogData( m_buffer, block2, " Read (controller->buffer): ");
}
else

0 comments on commit a46f3f3

Please sign in to comment.
You can’t perform that action at this time.