diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-06 18:33:37 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-06 18:34:34 +0100 |
commit | ffbab4fbf218514845b8e5209aec044621b1f460 (patch) | |
tree | 2c8e78816fc5bb060af46b7a736bec025f375041 /src/libutil | |
parent | 18e4a975983c7f61134c02d414170af678308bcb (diff) | |
download | rspamd-ffbab4fbf218514845b8e5209aec044621b1f460.tar.gz rspamd-ffbab4fbf218514845b8e5209aec044621b1f460.zip |
[CritFix] Fix leak in `gzip` function
Issue: #4564
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/util.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c index 4be7cc620..deba3e807 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -1,11 +1,11 @@ -/*- - * Copyright 2017 Vsevolod Stakhov +/* + * Copyright 2023 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -2231,6 +2231,7 @@ rspamd_fstring_gzip(rspamd_fstring_t **in) strm.avail_out = sizeof(temp) > buf->allocated ? buf->allocated : sizeof(temp); ret = deflate(&strm, Z_FINISH); if (ret == Z_STREAM_ERROR) { + deflateEnd(&strm); return FALSE; } @@ -2247,6 +2248,8 @@ rspamd_fstring_gzip(rspamd_fstring_t **in) if (ret != Z_BUF_ERROR || strm.avail_in == 0) { buf->len = strm.next_out - (unsigned char *) buf->str; *in = buf; + deflateEnd(&strm); + return ret == Z_STREAM_END; } } @@ -2267,6 +2270,7 @@ rspamd_fstring_gzip(rspamd_fstring_t **in) g_free(hold); buf->len = strm.next_out - (unsigned char *) buf->str; *in = buf; + deflateEnd(&strm); return ret == Z_STREAM_END; } |