aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/websocket
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2019-11-03 14:55:48 -0800
committerGarrett D'Amore <garrett@damore.org>2019-11-11 20:59:20 -0800
commit4b87eb768711cc6ed892d0d7b5afa9874b9f5c7b (patch)
tree5a3517d755166f09b53a565dcef81c13d5d2f23a /src/supplemental/websocket
parent21b40e0b51c39a19574c1fe79a48872558189770 (diff)
downloadnng-4b87eb768711cc6ed892d0d7b5afa9874b9f5c7b.tar.gz
nng-4b87eb768711cc6ed892d0d7b5afa9874b9f5c7b.tar.bz2
nng-4b87eb768711cc6ed892d0d7b5afa9874b9f5c7b.zip
fixes #1004 Warning found by clang --analyze
It's possible for an empty chunk to have a NULL data pointer. Even when copying zero bytes, this makes clang somewhat unhappy.
Diffstat (limited to 'src/supplemental/websocket')
-rw-r--r--src/supplemental/websocket/websocket.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/supplemental/websocket/websocket.c b/src/supplemental/websocket/websocket.c
index fe01c6e5..29d09c0e 100644
--- a/src/supplemental/websocket/websocket.c
+++ b/src/supplemental/websocket/websocket.c
@@ -846,12 +846,14 @@ ws_read_finish_str(nni_ws *ws)
// This eats the entire iov.
n = iov->iov_len;
}
- memcpy(iov->iov_buf, frame->buf, n);
- iov->iov_buf = ((uint8_t *) iov->iov_buf) + n;
- iov->iov_len -= n;
- if (iov->iov_len == 0) {
- iov++;
- niov--;
+ if (n != 0) {
+ memcpy(iov->iov_buf, frame->buf, n);
+ iov->iov_buf = ((uint8_t *) iov->iov_buf) + n;
+ iov->iov_len -= n;
+ if (iov->iov_len == 0) {
+ iov++;
+ niov--;
+ }
}
if (frame->len == n) {