diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gzip.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -65,13 +65,13 @@ static int _opkg_opk_gzip_next_record_from_file(struct opkg_opk_gzip_state *state) { for (;;) { - if (feof(state->input_file)) { - fclose(state->input_file); - state->input_file = NULL; - inflateEnd(&state->stream); - return OPKG_OPK_OK; - } if (state->stream.avail_in == 0) { + if (feof(state->input_file)) { + fclose(state->input_file); + state->input_file = NULL; + inflateEnd(&state->stream); + return OPKG_OPK_ERROR; + } state->stream.avail_in = fread(state->input_buffer, 1, OPKG_OPK_GZIP_BUFFER_SIZE, state->input_file); @@ -88,9 +88,13 @@ _opkg_opk_gzip_next_record_from_file(struct opkg_opk_gzip_state *state) } switch (inflate(&state->stream, Z_SYNC_FLUSH)) { case Z_OK: - case Z_STREAM_END: case Z_BUF_ERROR: break; + case Z_STREAM_END: + fclose(state->input_file); + state->input_file = NULL; + inflateEnd(&state->stream); + return OPKG_OPK_END; default: fclose(state->input_file); state->input_file = NULL; |