OSDN Git Service

Fix potential null point dereference
authorTed Wang <tedwang@google.com>
Fri, 29 Mar 2019 08:20:27 +0000 (16:20 +0800)
committerTed Wang <tedwang@google.com>
Fri, 29 Mar 2019 08:30:10 +0000 (16:30 +0800)
Use find() to check element in map to avoid unknow element been insert
into map causing null point dereference.

Bug: 121310341
Test: Manual connect/disconnect headset
Change-Id: If127086ec4beb9b735ef3c72456e8e2209826b57

profile/avrcp/connection_handler.cc

index 0530a21..3177506 100644 (file)
@@ -389,7 +389,7 @@ void ConnectionHandler::AcceptorControlCb(uint8_t handle, uint8_t event,
 
 void ConnectionHandler::MessageCb(uint8_t handle, uint8_t label, uint8_t opcode,
                                   tAVRC_MSG* p_msg) {
-  if (device_map_[handle] == nullptr) {
+  if (device_map_.find(handle) == device_map_.end()) {
     LOG(ERROR) << "Message received for unconnected device: handle="
                << loghex(handle);
     return;