Fix #272 - NULL argument check in MyMessage::set(char *)

This commit is contained in:
Henrik Ekblad
2015-11-30 00:08:48 +01:00
parent 7f468df165
commit 6d97702b29
+5 -2
View File
@@ -200,10 +200,13 @@ MyMessage& MyMessage::set(void* value, uint8_t length) {
}
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);
miSetPayloadType(P_STRING);
strncpy(data, value, length);
if (length)
strncpy(data, value, length);
else
data[0] ='\0';
return *this;
}