初始化函数返回值的状态为 Z_ERRNO,修正 BrotliDecoderCreateInstance() 返回 NULL 时触发的 bug

* 之前的 int ret = 0; (0 stand for Z_OK),当 BrotliDecoderCreateInstance() 返回 NULL 时,ret 的值不会修改,仍是 Z_OK
This commit is contained in:
luwenpeng
2019-09-26 10:12:36 +08:00
parent 509e45d018
commit 6a970cb29f

View File

@@ -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