summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/websock.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/websock.c b/src/websock.c
index f79feb5e..1b127c8b 100644
--- a/src/websock.c
+++ b/src/websock.c
@@ -45,7 +45,7 @@
#define FRAME_SET_RSV3(BYTE) (((BYTE) & 0x01) << 4)
#define FRAME_SET_OPCODE(BYTE) ((BYTE) & 0x0F)
#define FRAME_SET_MASK(BYTE) (((BYTE) & 0x01) << 7)
-#define FRAME_SET_LENGTH(X64, IDX) (unsigned char)(((X64) >> ((IDX)*8)) & 0xFF)
+#define FRAME_SET_LENGTH(X64, IDX) (unsigned char)((sizeof(X64)) <= (IDX) ? 0 : (((X64) >> ((IDX)*8)) & 0xFF))
#define OPCODE_CONTINUATION 0x0
#define OPCODE_TEXT 0x1