diff --git a/utils/common/src/light_animation_ipc.cpp b/utils/common/src/light_animation_ipc.cpp index 335b072f81ae72c154bc10eff96d1a8f599fd05e..be4afef286775dfddc67b99c65c48378f310429e 100644 --- a/utils/common/src/light_animation_ipc.cpp +++ b/utils/common/src/light_animation_ipc.cpp @@ -74,6 +74,7 @@ LightAnimationIPC* LightAnimationIPC::Unmarshalling(Parcel &parcel) auto lightAnimation = new (std::nothrow) LightAnimationIPC(); if (lightAnimation != nullptr && !lightAnimation->ReadFromParcel(parcel)) { MISC_HILOGE("ReadFromParcel is failed"); + delete lightAnimation; lightAnimation = nullptr; } return lightAnimation; diff --git a/utils/common/src/light_info_ipc.cpp b/utils/common/src/light_info_ipc.cpp index b9fb5af976927ee12412561bd2cac28fadaef372..6af8f10772feed0289907110dfa4547c77fa14c3 100644 --- a/utils/common/src/light_info_ipc.cpp +++ b/utils/common/src/light_info_ipc.cpp @@ -88,6 +88,7 @@ LightInfoIPC* LightInfoIPC::Unmarshalling(Parcel &parcel) auto lightInfo = new (std::nothrow) LightInfoIPC(); if (lightInfo != nullptr && !lightInfo->ReadFromParcel(parcel)) { MISC_HILOGE("ReadFromParcel is failed"); + delete lightInfo; lightInfo = nullptr; } return lightInfo; diff --git a/utils/common/src/vibrator_infos.cpp b/utils/common/src/vibrator_infos.cpp index e373e0a82e19f65b22b4e26c01ed93bfcc16d07b..e393932e2c4e4dba6285c651c132ee40432dafbe 100644 --- a/utils/common/src/vibrator_infos.cpp +++ b/utils/common/src/vibrator_infos.cpp @@ -98,16 +98,19 @@ VibratorCapacity* VibratorCapacity::Unmarshalling(Parcel &data) } if (!(data.ReadBool(capacity->isSupportHdHaptic))) { MISC_HILOGE("Read isSupportHdHaptic failed"); + delete capacity; capacity = nullptr; return capacity; } if (!(data.ReadBool(capacity->isSupportPresetMapping))) { MISC_HILOGE("Read isSupportPresetMapping failed"); + delete capacity; capacity = nullptr; return capacity; } if (!(data.ReadBool(capacity->isSupportTimeDelay))) { MISC_HILOGE("Read isSupportTimeDelay failed"); + delete capacity; capacity = nullptr; return capacity; } @@ -180,12 +183,16 @@ VibratePattern* VibratePattern::Unmarshalling(Parcel &data) auto pattern = new (std::nothrow) VibratePattern(); if (pattern == nullptr || !(data.ReadInt32(pattern->startTime)) || !(data.ReadInt32(pattern->patternDuration))) { MISC_HILOGE("Read pattern basic info failed"); - pattern = nullptr; + if (pattern != nullptr) { + delete pattern; + pattern = nullptr; + } return pattern; } int32_t eventSize{ 0 }; if (!(data.ReadInt32(eventSize)) || eventSize > MAX_EVENT_SIZE) { MISC_HILOGE("Read eventSize failed or eventSize exceed the maximum"); + delete pattern; pattern = nullptr; return pattern; } @@ -194,6 +201,7 @@ VibratePattern* VibratePattern::Unmarshalling(Parcel &data) int32_t tag{ -1 }; if (!data.ReadInt32(tag)) { MISC_HILOGE("Read type failed"); + delete pattern; pattern = nullptr; return pattern; } @@ -201,12 +209,14 @@ VibratePattern* VibratePattern::Unmarshalling(Parcel &data) if (!data.ReadInt32(event.time) || !data.ReadInt32(event.duration) || !data.ReadInt32(event.intensity) || !data.ReadInt32(event.frequency) || !data.ReadInt32(event.index)) { MISC_HILOGE("Read events info failed"); + delete pattern; pattern = nullptr; return pattern; } int32_t pointSize{ 0 }; if (!data.ReadInt32(pointSize) || pointSize > MAX_POINT_SIZE) { MISC_HILOGE("Read pointSize failed or pointSize exceed the maximum"); + delete pattern; pattern = nullptr; return pattern; } @@ -215,6 +225,7 @@ VibratePattern* VibratePattern::Unmarshalling(Parcel &data) VibrateCurvePoint point; if (!data.ReadInt32(point.time) || !data.ReadInt32(point.intensity) || !data.ReadInt32(point.frequency)) { MISC_HILOGE("Read points info time failed"); + delete pattern; pattern = nullptr; return pattern; } @@ -251,6 +262,7 @@ VibrateParameter* VibrateParameter::Unmarshalling(Parcel &data) } if (!(data.ReadInt32(parameter->intensity)) && !(data.ReadInt32(parameter->frequency))) { MISC_HILOGE("Read parameter's intensity failed"); + delete parameter; parameter = nullptr; } return parameter;