Skip to content

Commit 789e2b9

Browse files
authored
rc2014:network: fix network nullptr dereference (#1023)
If a protocol has failed to be established, and the written to, there is a nullptr dereference. Fix this.
1 parent b92235d commit 789e2b9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/device/rc2014/network.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,14 @@ void rc2014Network::write()
227227
rc2014_recv_buffer(response, num_bytes);
228228
rc2014_send_ack();
229229

230+
// If protocol isn't connected, then return not connected.
231+
if (protocol == nullptr)
232+
{
233+
network_status.error = NETWORK_ERROR_NOT_CONNECTED;
234+
rc2014_send_error();
235+
return;
236+
}
237+
230238
*transmitBuffer += string((char *)response, num_bytes);
231239
err = write_channel(num_bytes);
232240

@@ -254,7 +262,7 @@ void rc2014Network::read()
254262
// If protocol isn't connected, then return not connected.
255263
if (protocol == nullptr)
256264
{
257-
network_status.error = NETWORK_ERROR_COULD_NOT_ALLOCATE_BUFFERS;
265+
network_status.error = NETWORK_ERROR_NOT_CONNECTED;
258266
rc2014_send_error();
259267
return;
260268
}

0 commit comments

Comments
 (0)