From 6a970cb29f50d90ca6094a274943bc20d87a2680 Mon Sep 17 00:00:00 2001 From: luwenpeng Date: Thu, 26 Sep 2019 10:12:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC=E7=9A=84=E7=8A=B6=E6=80=81=E4=B8=BA?= =?UTF-8?q?=20Z=5FERRNO=EF=BC=8C=E4=BF=AE=E6=AD=A3=20BrotliDecoderCreateIn?= =?UTF-8?q?stance()=20=E8=BF=94=E5=9B=9E=20NULL=20=E6=97=B6=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 之前的 int ret = 0; (0 stand for Z_OK),当 BrotliDecoderCreateInstance() 返回 NULL 时,ret 的值不会修改,仍是 Z_OK --- plugin/protocol/http2/src/http2_common.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plugin/protocol/http2/src/http2_common.cpp b/plugin/protocol/http2/src/http2_common.cpp index b8b2a2c..0eb2521 100644 --- a/plugin/protocol/http2/src/http2_common.cpp +++ b/plugin/protocol/http2/src/http2_common.cpp @@ -151,7 +151,8 @@ int inflate_init(struct z_stream_st **strm, int gzip) (*strm)->zst.avail_in = 0; (*strm)->zst.next_in = Z_NULL; - int ret = 0; + // Z_OK stand for 0; Z_ERRNO stand for -1. + int ret = Z_ERRNO; if (gzip == HTTP2_CONTENT_ENCODING_GZIP) ret = inflateInit2(&((*strm)->zst), MAX_WBITS + 16); else if (gzip == HTTP2_CONTENT_ENCODING_DEFLATE) @@ -168,7 +169,7 @@ int inflate_init(struct z_stream_st **strm, int gzip) return ret; } -int inflate_br_read(struct z_stream_st **strm, const uint8_t *source, int len, +static int inflate_br_read(struct z_stream_st **strm, const uint8_t *source, int len, char **dest, int *outlen) { #define CHUNK (1024 * 1024 * 4) @@ -210,7 +211,7 @@ finish: return ret; } -int inflate_gzip_read(struct z_stream_st **strm, char **dest, int *outlen) +static int inflate_gzip_read(struct z_stream_st **strm, char **dest, int *outlen) { #define CHUNK (1024 * 1024 * 4) int ret = -1; @@ -269,7 +270,7 @@ int deflate_init(struct z_stream_st **strm, int gzip) if (*strm != NULL) return Z_OK; - int ret = 0; + int ret = 0; // 0 stand for Z_OK *strm = ALLOC(struct z_stream_st, 1); assert(*strm); @@ -304,7 +305,7 @@ int deflate_init(struct z_stream_st **strm, int gzip) return ret; } -int deflate_br_write(struct z_stream_st **strm, +static int deflate_br_write(struct z_stream_st **strm, const unsigned char * source, size_t slen, struct evbuffer * evbuf, int end) { @@ -353,7 +354,7 @@ int deflate_br_write(struct z_stream_st **strm, } -int defalta_gzip_write(struct z_stream_st **strm, const uint8_t *source, int slen, +static int defalta_gzip_write(struct z_stream_st **strm, const uint8_t *source, int slen, struct evbuffer * evbuf, int end) { #define SZ_IOVEC 2 @@ -440,7 +441,7 @@ void deflate_finished(struct z_stream_st **strm) BrotliEncoderDestroyInstance((*strm)->brenc_state); (*strm)->brenc_state = NULL; goto finish; - + } (void) deflateEnd(&((*strm)->zst)); finish: