Fix -Wmissing-field-initializers

This commit is contained in:
Alex Hultman
2020-11-30 23:37:49 +01:00
parent a6a2a648c9
commit 1c5d201846
3 changed files with 6 additions and 4 deletions
+2 -2
View File
@@ -160,14 +160,14 @@ struct CloseFrame {
static inline CloseFrame parseClosePayload(char *src, size_t length) {
/* If we get no code or message, default to reporting 1005 no status code present */
CloseFrame cf = {1005};
CloseFrame cf = {1005, nullptr, 0};
if (length >= 2) {
memcpy(&cf.code, src, 2);
cf = {cond_byte_swap<uint16_t>(cf.code), src + 2, length - 2};
if (cf.code < 1000 || cf.code > 4999 || (cf.code > 1011 && cf.code < 4000) ||
(cf.code >= 1004 && cf.code <= 1006) || !isValidUtf8((unsigned char *) cf.message, cf.length)) {
/* Even though we got a WebSocket close frame, it in itself is abnormal */
return {1006};
return {1006, nullptr, 0};
}
}
return cf;