diff --git a/utils/common/src/active_info.cpp b/utils/common/src/active_info.cpp index 03e1bad5ad81c7c9045052c763c6e0f95f5b951c..abf410dd413de372d19c850429105afc9d21fa78 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 0a4885ec3d1eea3771d0831a500817ec9b7ad6e1..68ec8f1685a2837f05c165a9fd02b64ef445c536 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;