--- a/gzwrite.c 2010-01-18 21:18:27.000000000 +0100 +++ b/gzwrite.c 2010-01-28 04:37:20.330530306 +0100 @@ -435,7 +435,8 @@ state = (gz_statep)file; /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE|| state->err != Z_OK) + if (state->mode != GZ_WRITE || state->err != Z_OK) + return Z_STREAM_ERROR; /* check flush parameter */ if (flush < 0 || flush > Z_FINISH)