From badf9b2d6a207584abeda1c30b563ebf9ec9f7cc Mon Sep 17 00:00:00 2001 From: lixiangpeng5 Date: Mon, 15 Jul 2024 14:06:39 +0000 Subject: [PATCH] fix uaf Signed-off-by: lixiangpeng5 Change-Id: I84668e48f593529dff0c1c8895f364b021dc2045 --- frameworks/native/src/sensor_agent_proxy.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/frameworks/native/src/sensor_agent_proxy.cpp b/frameworks/native/src/sensor_agent_proxy.cpp index 74040929..a714a3cb 100644 --- a/frameworks/native/src/sensor_agent_proxy.cpp +++ b/frameworks/native/src/sensor_agent_proxy.cpp @@ -182,15 +182,13 @@ int32_t SensorAgentProxy::DeactivateSensor(int32_t sensorId, const SensorUser *u SEN_HILOGE("Subscribe user first"); return OHOS::Sensors::ERROR; } - subscribeSet.erase(user); - if (subscribeSet.empty()) { - subscribeMap_.erase(sensorId); - } auto status = unsubscribeMap_[sensorId].insert(user); if (!status.second) { SEN_HILOGD("User has been unsubscribed"); } + subscribeSet.erase(user); if (subscribeSet.empty()) { + subscribeMap_.erase(sensorId); int32_t ret = SEN_CLIENT.DisableSensor(sensorId); if (ret != 0) { SEN_HILOGE("DisableSensor failed, ret:%{public}d", ret); -- Gitee