mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-13 23:45:25 +00:00
Fixed NULL access
This commit is contained in:
parent
2a20893a58
commit
376cd0cf90
@ -866,6 +866,8 @@ uint8_t AmsConfiguration::getTempSensorCount() {
|
||||
}
|
||||
|
||||
TempSensorConfig* AmsConfiguration::getTempSensorConfig(uint8_t address[8]) {
|
||||
if(tempSensors == NULL)
|
||||
return NULL;
|
||||
for(int x = 0; x < tempSensorCount; x++) {
|
||||
TempSensorConfig *conf = tempSensors[x];
|
||||
if(isSensorAddressEqual(conf->address, address)) {
|
||||
@ -877,14 +879,16 @@ TempSensorConfig* AmsConfiguration::getTempSensorConfig(uint8_t address[8]) {
|
||||
|
||||
void AmsConfiguration::updateTempSensorConfig(uint8_t address[8], const char name[32], bool common) {
|
||||
bool found = false;
|
||||
for(int x = 0; x < tempSensorCount; x++) {
|
||||
TempSensorConfig *data = tempSensors[x];
|
||||
if(isSensorAddressEqual(data->address, address)) {
|
||||
found = true;
|
||||
strcpy(data->name, name);
|
||||
data->common = common;
|
||||
}
|
||||
}
|
||||
if(tempSensors != NULL) {
|
||||
for(int x = 0; x < tempSensorCount; x++) {
|
||||
TempSensorConfig *data = tempSensors[x];
|
||||
if(isSensorAddressEqual(data->address, address)) {
|
||||
found = true;
|
||||
strcpy(data->name, name);
|
||||
data->common = common;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!found) {
|
||||
TempSensorConfig** tempSensors = new TempSensorConfig*[tempSensorCount+1];
|
||||
if(this->tempSensors != NULL) {
|
||||
|
||||
@ -319,7 +319,7 @@ private:
|
||||
bool wifiChanged, mqttChanged, meterChanged = true, domoChanged, ntpChanged = true, entsoeChanged = false;
|
||||
|
||||
uint8_t tempSensorCount = 0;
|
||||
TempSensorConfig** tempSensors;
|
||||
TempSensorConfig** tempSensors = NULL;
|
||||
|
||||
bool loadConfig83(int address);
|
||||
bool relocateConfig86();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user