From: Ted Wang Date: Fri, 29 Mar 2019 08:20:27 +0000 (+0800) Subject: Fix potential null point dereference X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=48af6209df617d8f532a2114ab5befabe27c6099;p=android-x86%2Fsystem-bt.git Fix potential null point dereference 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 --- diff --git a/profile/avrcp/connection_handler.cc b/profile/avrcp/connection_handler.cc index 0530a2153..3177506a1 100644 --- a/profile/avrcp/connection_handler.cc +++ b/profile/avrcp/connection_handler.cc @@ -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;