More checks in mg_ws_send

This commit is contained in:
cpq 2021-01-02 12:20:08 +00:00
parent 2f9d2bbdf6
commit 1b0636c2d2
2 changed files with 2 additions and 2 deletions

View File

@ -3941,7 +3941,7 @@ size_t mg_ws_send(struct mg_connection *c, const char *buf, size_t len,
}
LOG(LL_VERBOSE_DEBUG, ("WS out: %d [%.*s]", (int) len, (int) len, buf));
mg_send(c, buf, len);
if (c->is_client) {
if (c->is_client && c->send.buf != NULL) {
uint8_t *p = c->send.buf + c->send.len - len;
for (i = 0; i < len; i++) p[i] ^= mask[i & 3];
}

View File

@ -95,7 +95,7 @@ size_t mg_ws_send(struct mg_connection *c, const char *buf, size_t len,
}
LOG(LL_VERBOSE_DEBUG, ("WS out: %d [%.*s]", (int) len, (int) len, buf));
mg_send(c, buf, len);
if (c->is_client) {
if (c->is_client && c->send.buf != NULL) {
uint8_t *p = c->send.buf + c->send.len - len;
for (i = 0; i < len; i++) p[i] ^= mask[i & 3];
}