Since gzclose() closes the file and deallocates the data structure for
it it is not possible to call gzerror() using the file that was just
closed even on error.

--- zlib-1.2.3/zlib.h.orig	2006-02-18 08:37:38.000000000 +0000
+++ zlib-1.2.3/zlib.h	2006-02-25 12:02:18.000000000 +0000
@@ -1230,7 +1230,8 @@
 /*
      Flushes all pending output if necessary, closes the compressed file
    and deallocates all the (de)compression state. The return value is the zlib
-   error number (see function gzerror below).
+   error number (see function gzerror below).  Note that even when an error
+   is returned the file will be closed so gzerror cannot be called.
 */
 
 ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
