From 5e858177e4643a77eb8d5c5cb37ce1be929d53eb Mon Sep 17 00:00:00 2001 From: shenpeixing Date: Tue, 29 Apr 2025 12:07:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=AF=E8=83=BD=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shenpeixing --- utils/common/src/active_info.cpp | 5 ++++- utils/common/src/sensor.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/common/src/active_info.cpp b/utils/common/src/active_info.cpp index 03e1bad5..abf410dd 100644 --- a/utils/common/src/active_info.cpp +++ b/utils/common/src/active_info.cpp @@ -99,7 +99,10 @@ ActiveInfo* ActiveInfo::Unmarshalling(Parcel &parcel) if (activeInfo == nullptr || !(parcel.ReadInt32(pid) && parcel.ReadInt32(sensorId) && parcel.ReadInt64(samplingPeriodNs) && parcel.ReadInt64(maxReportDelayNs))) { SEN_HILOGE("Read from parcel is failed"); - activeInfo = nullptr; + if (activeInfo != nullptr) { + delete activeInfo; + activeInfo = nullptr; + } return activeInfo; } activeInfo->SetPid(pid); diff --git a/utils/common/src/sensor.cpp b/utils/common/src/sensor.cpp index 0a4885ec..68ec8f16 100644 --- a/utils/common/src/sensor.cpp +++ b/utils/common/src/sensor.cpp @@ -232,6 +232,7 @@ Sensor* Sensor::Unmarshalling(Parcel &parcel) auto sensor = new (std::nothrow) Sensor(); if (sensor != nullptr && !sensor->ReadFromParcel(parcel)) { SEN_HILOGE("ReadFromParcel is failed"); + delete sensor; sensor = nullptr; } return sensor; -- Gitee