Wireshark-dev: Re: [Wireshark-dev] SVN revision 36552 on Debian Lenny and gzopen64 function

From: Jakub Zawadzki <darkjames@xxxxxxxxxxxxxxxx>
Date: Tue, 12 Apr 2011 09:36:34 +0200
On Mon, Apr 11, 2011 at 02:36:17PM -0700, Guy Harris wrote:
>
> On Apr 11, 2011, at 9:12 AM, Guy Harris wrote:
>
> > I'll look at getting rid of the use of the zlib gz* routines for
> > output (just as we've done for input)
>
> Done, as of revision 36563.

Attaching some small fixes.

btw. what do you think about merging GZWFILE_T and WFILE_T?
(i.e. using one API for writting files, wfile_open(), wfile_write(), ...)
diff --git wiretap/file_wrappers.c wiretap/file_wrappers.c
index 633204a..4f2900f 100644
--- wiretap/file_wrappers.c
+++ wiretap/file_wrappers.c
@@ -1018,7 +1043,7 @@ gzwfile_open(const char *path)
     if (state == NULL) {
     	save_errno = errno;
         close(fd);
-        save_errno = errno;
+        errno = save_errno;
     }
     return state;
 }
@@ -1061,10 +1086,8 @@ gz_init(GZWFILE_T state)
     state->in = g_try_malloc(state->want);
     state->out = g_try_malloc(state->want);
     if (state->in == NULL || state->out == NULL) {
-        if (state->out != NULL)
-            g_free(state->out);
-        if (state->in != NULL)
-            g_free(state->in);
+        g_free(state->out);
+        g_free(state->in);
         state->err = WTAP_ERR_ZLIB + Z_MEM_ERROR;	/* ENOMEM? */
         return -1;
     }
@@ -1076,6 +1099,7 @@ gz_init(GZWFILE_T state)
     ret = deflateInit2(strm, state->level, Z_DEFLATED,
                        15 + 16, 8, state->strategy);
     if (ret != Z_OK) {
+        g_free(state->out);
         g_free(state->in);
         state->err = WTAP_ERR_ZLIB + Z_MEM_ERROR;	/* ENOMEM? */
         return -1;