Fix crash

This commit is contained in:
Stephan Hadinger 2020-03-17 23:00:40 +01:00
parent 03ef61c426
commit 43ea0b6356
1 changed files with 3 additions and 1 deletions

View File

@ -340,7 +340,9 @@ int32_t Z_DataConfirm(int32_t res, const class SBuffer &buf) {
char status_message[32];
if (status) { // only report errors
strncpy_P(status_message, (const char*) getZigbeeStatusMessage(status), sizeof(status_message));
const char * statm = (const char*) getZigbeeStatusMessage(status);
if (nullptr == statm) { statm = PSTR(""); }
strncpy_P(status_message, statm, 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"