Fix SEGV in handleThermostatClusterIndication()
If a thermostat cluster command is received but no sensor for that device exists,
the sensor resource pointer wasn't checked and a null pointer deref ended up in SEGV.
Issue:
Fix based on core dump  core-deCONZ-sig11-user1000-group1000-pid28984-time1596024251
@@ -102,6 +102,12 @@ void DeRestPluginPrivate::handleThermostatClusterIndication(const deCONZ::ApsDat
{
Sensor *sensor = getSensorNodeForAddressAndEndpoint(ind.srcAddress(), ind.srcEndpoint());
+ if (!sensor)
+ {
+ DBG_Printf(DBG_INFO, "No thermostat sensor found for 0x%016llX, endpoint: 0x%08X\n", ind.srcAddress().ext(), ind.srcEndpoint());
+ return;
+ }
+
QDataStream stream(zclFrame.payload());
stream.setByteOrder(QDataStream::LittleEndian);
@@ -153,11 +159,6 @@ void DeRestPluginPrivate::handleThermostatClusterIndication(const deCONZ::ApsDat
continue;
}
- if (!sensor)
- {
- continue;
- }
-
ResourceItem *item = nullptr;
switch (attrId)
@@ -572,7 +573,6 @@ void DeRestPluginPrivate::handleThermostatClusterIndication(const deCONZ::ApsDat
item->setValue(sched);
}
}
-
}
