mirror of https://github.com/arendst/Tasmota.git
Fix potential crash.
getZigbeeStatusMessage() does not return null anymore but empty string if the code is not found.
This commit is contained in:
parent
ca07ab5417
commit
b438a9e1e4
|
@ -474,7 +474,7 @@ const __FlashStringHelper* getZigbeeStatusMessage(uint8_t status) {
|
|||
return (const __FlashStringHelper*) statl->status_msg;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
return F("");
|
||||
}
|
||||
|
||||
#endif // USE_ZIGBEE
|
||||
|
|
|
@ -506,10 +506,7 @@ void ZCLFrame::parseResponse(void) {
|
|||
// "Status"
|
||||
json[F(D_JSON_ZIGBEE_STATUS)] = status;
|
||||
// "StatusMessage"
|
||||
const __FlashStringHelper* statm = getZigbeeStatusMessage(status);
|
||||
if (statm) {
|
||||
json[F(D_JSON_ZIGBEE_STATUS_MSG)] = statm;
|
||||
}
|
||||
json[F(D_JSON_ZIGBEE_STATUS_MSG)] = getZigbeeStatusMessage(status);
|
||||
// Add Endpoint
|
||||
json[F(D_CMND_ZIGBEE_ENDPOINT)] = _srcendpoint;
|
||||
// Add Group if non-zero
|
||||
|
|
|
@ -347,9 +347,7 @@ int32_t Z_DataConfirm(int32_t res, const class SBuffer &buf) {
|
|||
char status_message[32];
|
||||
|
||||
if (status) { // only report errors
|
||||
const char * statm = (const char*) getZigbeeStatusMessage(status);
|
||||
if (nullptr == statm) { statm = PSTR(""); }
|
||||
strncpy_P(status_message, statm, sizeof(status_message));
|
||||
strncpy_P(status_message, (const char*) getZigbeeStatusMessage(status), sizeof(status_message));
|
||||
status_message[sizeof(status_message)-1] = 0; // truncate if needed, strlcpy is safer but strlcpy_P does not exist
|
||||
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_CONFIRM "\":{\"" D_CMND_ZIGBEE_ENDPOINT "\":%d"
|
||||
|
|
Loading…
Reference in New Issue