Fix memory leak when writing compressed sav files
[pspp] / src / data / sys-file-writer.c
index e0c6eade4b158d81e457bdb263b490828500d6a8..3350a344854efcda877623822b7e9868b21898bb 100644 (file)
@@ -33,7 +33,6 @@
 #include "data/casewriter.h"
 #include "data/dictionary.h"
 #include "data/file-handle-def.h"
-#include "data/file-name.h"
 #include "data/format.h"
 #include "data/make-file.h"
 #include "data/missing-values.h"
@@ -251,8 +250,7 @@ sfm_open_writer (struct file_handle *fh, struct dictionary *d,
   mode = 0444;
   if (opts.create_writeable)
     mode |= 0222;
-  w->rf = replace_file_start (fh_get_file_name (fh), "wb", mode,
-                              &w->file, NULL);
+  w->rf = replace_file_start (fh, "wb", mode, &w->file);
   if (w->rf == NULL)
     {
       msg (ME, _("Error opening `%s' for writing as a system file: %s."),
@@ -1422,6 +1420,7 @@ finish_zstream (struct sfm_writer *w)
   block = &w->blocks[w->n_blocks++];
   block->uncompressed_size = w->zstream.total_in;
   block->compressed_size = w->zstream.total_out;
+  deflateEnd (&w->zstream);
 }
 
 static void