aboutsummaryrefslogtreecommitdiff
path: root/src/http/v2/ngx_http_v2_huff_encode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/v2/ngx_http_v2_huff_encode.c')
-rw-r--r--src/http/v2/ngx_http_v2_huff_encode.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/http/v2/ngx_http_v2_huff_encode.c b/src/http/v2/ngx_http_v2_huff_encode.c
index 16c154bdf..3f822cd0b 100644
--- a/src/http/v2/ngx_http_v2_huff_encode.c
+++ b/src/http/v2/ngx_http_v2_huff_encode.c
@@ -231,6 +231,10 @@ ngx_http_v2_huff_encode(u_char *src, size_t len, u_char *dst, ngx_uint_t lower)
buf = pending ? code << (sizeof(buf) * 8 - pending) : 0;
}
+ if (pending == 0) {
+ return hlen;
+ }
+
buf |= (ngx_uint_t) -1 >> pending;
pending = ngx_align(pending, 8);
@@ -241,10 +245,10 @@ ngx_http_v2_huff_encode(u_char *src, size_t len, u_char *dst, ngx_uint_t lower)
buf >>= sizeof(buf) * 8 - pending;
- while (pending) {
+ do {
pending -= 8;
dst[hlen++] = (u_char) (buf >> pending);
- }
+ } while (pending);
return hlen;
}