Skip to content

Commit

Permalink
Correct the selection of alloc/free functions for zlib.
Browse files Browse the repository at this point in the history
Avoids segfault when working with zlib-ng.
See:
zlib-ng/zlib-ng#1708
  • Loading branch information
jo-oe authored and scott-ferguson-unity committed Jun 24, 2024
1 parent 4a14a72 commit 05a6e0e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions support/zlib-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ CreateZStream (gint compress, guchar gzip, read_write_func func, void *gchandle)
return NULL;

z = z_new0 (z_stream);
z->zalloc = z_alloc;
z->zfree = z_free;
if (compress) {
retval = deflateInit2 (z, Z_DEFAULT_COMPRESSION, Z_DEFLATED, gzip ? 31 : -15, 8, Z_DEFAULT_STRATEGY);
} else {
Expand All @@ -86,8 +88,6 @@ CreateZStream (gint compress, guchar gzip, read_write_func func, void *gchandle)
free (z);
return NULL;
}
z->zalloc = z_alloc;
z->zfree = z_free;
result = z_new0 (ZStream);
result->stream = z;
result->func = func;
Expand Down

0 comments on commit 05a6e0e

Please sign in to comment.