Skip to content

Commit 74e566f

Browse files
tekka007mfalkvidd
authored andcommitted
Fix segmentation fault (#1346)
1 parent 40ba986 commit 74e566f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/MyProtocol.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ bool protocolSerial2MyMessage(MyMessage &message, char *inputString)
6060
}
6161
}
6262
// payload
63-
if (command == C_STREAM) {
63+
if (str == NULL) {
64+
// no payload, set default value
65+
message.set((uint8_t)0);
66+
} else if (command == C_STREAM) {
67+
// stream payload
6468
uint8_t bvalue[MAX_PAYLOAD_SIZE];
6569
uint8_t blen = 0;
6670
while (*str) {
@@ -72,6 +76,7 @@ bool protocolSerial2MyMessage(MyMessage &message, char *inputString)
7276
}
7377
message.set(bvalue, blen);
7478
} else {
79+
// regular payload
7580
char *value = str;
7681
// Remove trailing carriage return and newline character (if it exists)
7782
const uint8_t lastCharacter = strlen(value) - 1;

0 commit comments

Comments
 (0)