Merge pull request #273 from mysensors/null-check-fix
This commit is contained in:
@@ -200,10 +200,13 @@ MyMessage& MyMessage::set(void* value, uint8_t length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MyMessage& MyMessage::set(const char* value) {
|
MyMessage& MyMessage::set(const char* value) {
|
||||||
uint8_t length = min(strlen(value), MAX_PAYLOAD);
|
uint8_t length = value == NULL ? 0 : min(strlen(value), MAX_PAYLOAD);
|
||||||
miSetLength(length);
|
miSetLength(length);
|
||||||
miSetPayloadType(P_STRING);
|
miSetPayloadType(P_STRING);
|
||||||
strncpy(data, value, length);
|
if (length)
|
||||||
|
strncpy(data, value, length);
|
||||||
|
else
|
||||||
|
data[0] ='\0';
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user