From 0ac11ea822215eb6524cea9fcac7bf8a4c642129 Mon Sep 17 00:00:00 2001 From: tcave-bb <90306563+tcave-bb@users.noreply.github.com> Date: Mon, 21 Aug 2023 12:18:20 +0100 Subject: [PATCH] Bug/air quality sensor app leak (#28619) * free handle on error * corrected README.md * Restyled by prettier-markdown * updated readme * Restyled by prettier-markdown --------- Co-authored-by: Restyled.io --- .../linux/AirQualitySensorAppAttrUpdateDelegate.cpp | 5 ++++- examples/air-quality-sensor-app/linux/README.md | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/air-quality-sensor-app/linux/AirQualitySensorAppAttrUpdateDelegate.cpp b/examples/air-quality-sensor-app/linux/AirQualitySensorAppAttrUpdateDelegate.cpp index aea583d910bf12..7489a9ac9d7aaa 100644 --- a/examples/air-quality-sensor-app/linux/AirQualitySensorAppAttrUpdateDelegate.cpp +++ b/examples/air-quality-sensor-app/linux/AirQualitySensorAppAttrUpdateDelegate.cpp @@ -106,7 +106,10 @@ void AirQualitySensorAttrUpdateHandler::HandleCommand(intptr_t context) auto * self = reinterpret_cast(context); std::string clusterName = self->mJsonValue["Name"].asString(); - VerifyOrReturn(!self->mJsonValue.empty(), ChipLogError(NotSpecified, "Invalid JSON event command received")); + VerifyOrReturn(!self->mJsonValue.empty(), { + ChipLogError(NotSpecified, "Invalid JSON event command received"); + Platform::Delete(self); + }); if (clusterName == "AirQuality") { diff --git a/examples/air-quality-sensor-app/linux/README.md b/examples/air-quality-sensor-app/linux/README.md index a8710d62f0e3c5..51798c23ef441f 100644 --- a/examples/air-quality-sensor-app/linux/README.md +++ b/examples/air-quality-sensor-app/linux/README.md @@ -116,14 +116,14 @@ To cross-compile this example on x64 host and run on **NXP i.MX 8M Mini** ## Trigger event using air-quality-sensor-app event named pipe You can send a command to air-quality-sensor-app to trigger specific event via -air-quality-sensor-app event named pipe /tmp/chip_air_quality_fifo-. +air-quality-sensor-app event named pipe /tmp/chip_air_quality_fifo\*. ### Trigger air quality change event Generate event `AirQuality`, to change the air quality value. ``` -$ echo '{"Name":"AirQuality","NewValue":3}' > /tmp/chip_air_quality_fifo- +$ echo '{"Name":"AirQuality","NewValue":3}' > /tmp/chip_air_quality_fifo_ ``` ### Trigger Temperature change event @@ -131,7 +131,7 @@ $ echo '{"Name":"AirQuality","NewValue":3}' > /tmp/chip_air_quality_fifo- Generate event `TemperatureMeasurement`, to change the temperate value. ``` -$ echo '{"Name":"TemperatureMeasurement","NewValue":18}' > /tmp/chip_air_quality_fifo- +$ echo '{"Name":"TemperatureMeasurement","NewValue":18}' > /tmp/chip_air_quality_fifo_ ``` ### Trigger Humidity change event @@ -139,7 +139,7 @@ $ echo '{"Name":"TemperatureMeasurement","NewValue":18}' > /tmp/chip_air_quality Generate event `RelativeHumidityMeasurement`, to change the temperate value. ``` -$ echo '{"Name":"RelativeHumidityMeasurement","NewValue":60}' > /tmp/chip_air_quality_fifo- +$ echo '{"Name":"RelativeHumidityMeasurement","NewValue":60}' > /tmp/chip_air_quality_fifo_ ``` ### Trigger concentration change event @@ -150,5 +150,5 @@ clusters. Generate event `CarbonDioxideConcentrationMeasurement`, to change the CO2 value. ``` -$ echo '{"Name":"CarbonDioxideConcentrationMeasurement","NewValue":400}' > /tmp/chip_air_quality_fifo- +$ echo '{"Name":"CarbonDioxideConcentrationMeasurement","NewValue":400}' > /tmp/chip_air_quality_fifo_ ```