Silence an UBSAN fuzzing fault

This commit is contained in:
Alex Hultman
2020-01-01 17:41:43 +01:00
parent 9038988a48
commit 6fe5ea40aa
+4 -1
View File
@@ -167,7 +167,10 @@ static inline size_t formatClosePayload(char *dst, uint16_t code, const char *me
if (code) {
code = cond_byte_swap<uint16_t>(code);
memcpy(dst, &code, 2);
memcpy(dst + 2, message, length);
/* It is invalid to pass nullptr to memcpy, even though length is 0 */
if (message) {
memcpy(dst + 2, message, length);
}
return length + 2;
}
return 0;