diff options
| author | Hans Kristian Rosbach <hk-git@circlestorm.org> | 2025-08-20 16:24:16 +0200 |
|---|---|---|
| committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2025-08-23 17:25:17 +0200 |
| commit | 4c6ec4c5517b1950442225a97c8391626dca1bfe (patch) | |
| tree | 40f95bc70817de614b92667d242ad5502d84f6df | |
| parent | 9be91d646529a60b958b9eea826de6fb2dea2d62 (diff) | |
| download | Project-Tick-4c6ec4c5517b1950442225a97c8391626dca1bfe.tar.gz Project-Tick-4c6ec4c5517b1950442225a97c8391626dca1bfe.zip | |
Add error propagation to gzread/gzwrite
| -rw-r--r-- | gzread.c.in | 9 | ||||
| -rw-r--r-- | gzwrite.c | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/gzread.c.in b/gzread.c.in index 0c9d7e200e..91494b2ccb 100644 --- a/gzread.c.in +++ b/gzread.c.in @@ -25,9 +25,14 @@ static int gz_read_init(gz_state *state) { } /* Initialize inflate state */ - if (PREFIX(inflateInit2)(&(state->strm), MAX_WBITS + 16) != Z_OK) { + int ret = PREFIX(inflateInit2)(&(state->strm), MAX_WBITS + 16); + if (ret != Z_OK) { gz_buffer_free(state); - gz_error(state, Z_MEM_ERROR, "out of memory"); + if (ret == Z_MEM_ERROR) { + gz_error(state, Z_MEM_ERROR, "out of memory"); + } else { + gz_error(state, Z_STREAM_ERROR, "invalid compression parameters"); + } return -1; } return 0; @@ -29,10 +29,14 @@ static int gz_write_init(gz_state *state) { /* only need deflate state if compressing */ if (!state->direct) { /* allocate deflate memory, set up for gzip compression */ - ret = PREFIX(deflateInit2)(strm, state->level, Z_DEFLATED, MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); + int ret = PREFIX(deflateInit2)(strm, state->level, Z_DEFLATED, MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); if (ret != Z_OK) { gz_buffer_free(state); - gz_error(state, Z_MEM_ERROR, "out of memory"); + if (ret == Z_MEM_ERROR) { + gz_error(state, Z_MEM_ERROR, "out of memory"); + } else { + gz_error(state, Z_STREAM_ERROR, "invalid compression parameters"); + } return -1; } strm->next_in = NULL; |
