RemoteMessage: Guard against NULL source/target.

To make it more obvious in case it is ever used the wrong way.
This commit is contained in:
Michael Lotz 2017-11-21 21:28:21 +01:00
parent 703667a98d
commit 4d9d6d7ee3
2 changed files with 5 additions and 2 deletions

View File

@ -228,7 +228,7 @@ RemoteHWInterface::_EventThreadEntry(void* data)
status_t
RemoteHWInterface::_EventThread()
{
RemoteMessage message(fReceiveBuffer, fSendBuffer);
RemoteMessage message(fReceiveBuffer, NULL);
while (true) {
uint16 code;
status_t result = message.NextMessage(code);

View File

@ -239,7 +239,7 @@ RemoteMessage::Start(uint16 code)
inline status_t
RemoteMessage::Flush()
{
if (fWriteIndex == 0)
if (fWriteIndex == 0 || fTarget == NULL)
return B_NO_INIT;
uint32 length = fWriteIndex;
@ -304,6 +304,9 @@ RemoteMessage::Read(T& value)
if (fDataLeft < sizeof(T))
return B_ERROR;
if (fSource == NULL)
return B_NO_INIT;
int32 readSize = fSource->Read(&value, sizeof(T));
if (readSize < 0)
return readSize;