diff options
| author | Andrew Clayton <a.clayton@nginx.com> | 2025-08-22 17:47:21 +0100 |
|---|---|---|
| committer | Andrew Clayton <a.clayton@nginx.com> | 2025-08-25 16:16:37 +0100 |
| commit | a76c8a7b944e43f56ddbcac0b49832a0d7f91d8b (patch) | |
| tree | 3362e602a4dcade51fd5d316c724229c623d0d39 /src/nxt_brotli.c | |
| parent | ff7da85109221a5c1e49d2ee3279a9a046d26959 (diff) | |
| download | unit-a76c8a7b944e43f56ddbcac0b49832a0d7f91d8b.tar.gz unit-a76c8a7b944e43f56ddbcac0b49832a0d7f91d8b.tar.bz2 | |
http: compression: brotli: Don't leak memory on error
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src/nxt_brotli.c')
| -rw-r--r-- | src/nxt_brotli.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nxt_brotli.c b/src/nxt_brotli.c index 773b8b6f..c69d977e 100644 --- a/src/nxt_brotli.c +++ b/src/nxt_brotli.c @@ -46,14 +46,14 @@ nxt_brotli_compress(nxt_http_comp_compressor_ctx_t *ctx, const uint8_t *in_buf, &in_len, &in_buf, &out_bytes, &out_buf, NULL); if (!ok) { - return -1; + goto out_err_free; } ok = BrotliEncoderCompressStream(brotli, BROTLI_OPERATION_FLUSH, &in_len, &in_buf, &out_bytes, &out_buf, NULL); if (!ok) { - return -1; + goto out_err_free; } if (last) { @@ -61,13 +61,18 @@ nxt_brotli_compress(nxt_http_comp_compressor_ctx_t *ctx, const uint8_t *in_buf, &in_len, &in_buf, &out_bytes, &out_buf, NULL); if (!ok) { - return -1; + goto out_err_free; } BrotliEncoderDestroyInstance(brotli); } return out_len - out_bytes; + +out_err_free: + BrotliEncoderDestroyInstance(brotli); + + return -1; } |
