Fix null pointer dereference if node isn't in the node list
*** Aborted at 1684438270 (unix time) try "date -d @1684438270" if you are using GNU date ***
PC: @ 0x0 (unknown)
*** SIGSEGV (@0x0) received by PID 17002 (TID 0x7f90778700) from PID 0; stack trace: ***
@ 0x7f907856a0 ([vdso]+0x69f)
@ 0x270a3c aos::message_bridge::MessageBridgeServer::MaybeIncrementInvalidConnectionCount()
@ 0x2701c4 aos::message_bridge::MessageBridgeServer::HandleData()
@ 0x26f840 aos::message_bridge::MessageBridgeServer::MessageReceived()
@ 0x277954 std::__1::__function::__func<>::operator()()
@ 0x2b0e78 aos::internal::EPoll::InOutEventData::DoCallbacks()
@ 0x2b0c08 aos::internal::EPoll::Poll()
@ 0x2b0b10 aos::internal::EPoll::Run()
@ 0x2aad70 aos::ShmEventLoop::Run()
@ 0x24b1f0 aos::message_bridge::Main()
@ 0x24b550 main
@ 0x7f90523110 __libc_start_main
@ 0x24af34 (unknown)
audit: type=1701 audit(1684438270.337:116): auid=4294967295 uid=1000 gid=1000 ses=4294967295 pid=17002 comm="message_bridge_" exe="/app/bin/message_bridge_server" sig=11
This is the only logical explanation I've got for what could be wrong.
Change-Id: I5cb74879df748ff930984997ed2142f23f40e4f8
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/network/message_bridge_server_lib.cc b/aos/network/message_bridge_server_lib.cc
index 6b81856..8818ee2 100644
--- a/aos/network/message_bridge_server_lib.cc
+++ b/aos/network/message_bridge_server_lib.cc
@@ -530,8 +530,10 @@
ServerConnection *connection = server_status_.server_connection()[node_index];
- connection->mutate_invalid_connection_count(
- connection->invalid_connection_count() + 1);
+ if (connection != nullptr) {
+ connection->mutate_invalid_connection_count(
+ connection->invalid_connection_count() + 1);
+ }
}
void MessageBridgeServer::HandleData(const Message *message) {