Prevent potential segmentation fault
@@ -94,6 +94,9 @@ void DeRestPluginPrivate::handleXiaomiLumiClusterIndication(const deCONZ::ApsDat
// as presence = true state, but this is not reset by the device automatically. Ideally, deCONZ will have some timers
// for such cases available in future.
Sensor *sensor = getSensorNodeForAddressAndEndpoint(ind.srcAddress(), ind.srcEndpoint());
+
+ if (sensor)
+ {
bool occupancy = true;
ResourceItem *item = nullptr;
item = sensor->item(RStatePresence);
@@ -103,7 +106,8 @@ void DeRestPluginPrivate::handleXiaomiLumiClusterIndication(const deCONZ::ApsDat
item->setValue(occupancy);
enqueueEvent(Event(RSensors, RStatePresence, sensor->id(), item));
- ResourceItem *item2 = sensor->item(RConfigDuration);
+ ResourceItem *item2 = nullptr;
+ item2 = sensor->item(RConfigDuration);
if (item2 && item2->toNumber() > 0)
{
@@ -123,6 +127,7 @@ void DeRestPluginPrivate::handleXiaomiLumiClusterIndication(const deCONZ::ApsDat
sensor->setNeedSaveDatabase(true);
queSaveDb(DB_SENSORS, DB_SHORT_SAVE_DELAY);
}
+ }
break;
case XIAOMI_ATTRID_SPEED:
