Guard against SEGV while adding state changes
@@ -771,18 +771,26 @@ int DeRestPluginPrivate::changeSensorConfig(const ApiRequest &req, ApiResponse &
StateChange change(StateChange::StateWaitSync, SC_WriteZclAttribute, task.req.dstEndpoint());
change.addTargetValue(rid.suffix, data.string);
Resource *rsub = DEV_GetSubDevice(device, nullptr, sensor->uniqueId());
+
+ if (rsub)
+ {
rsub->addStateChange(change);
updated = true;
}
}
+ }
else if (rid.suffix == RConfigClickMode && !data.string.isEmpty()) // String
{
StateChange change(StateChange::StateWaitSync, SC_WriteZclAttribute, task.req.dstEndpoint());
change.addTargetValue(rid.suffix, data.string);
Resource *rsub = DEV_GetSubDevice(device, nullptr, sensor->uniqueId());
+
+ if (rsub)
+ {
rsub->addStateChange(change);
updated = true;
}
+ }
else if (rid.suffix == RConfigTholdDark || rid.suffix == RConfigTholdOffset) // Unsigned integer
{
tholdUpdated = true;
