MATRIX SAVE negative tests
[pspp] / src / language / stats / matrix.c
index d90cd2a326bc436bfae9bf7db3031a0f8e94e94d..a145282b1237575e73215d5469a5540d37f22e0f 100644 (file)
@@ -4370,7 +4370,7 @@ save_file_create (struct matrix_state *s, struct file_handle *fh,
   for (size_t i = 0; i < s->n_save_files; i++)
     {
       struct save_file *sf = s->save_files[i];
-      if (sf->file == fh)
+      if (fh_equal (sf->file, fh))
         {
           fh_unref (fh);
 
@@ -4518,16 +4518,16 @@ save_file_destroy (struct save_file *sf)
         {
           dataset_set_dict (sf->dataset, sf->dict);
           dataset_set_source (sf->dataset, casewriter_make_reader (sf->writer));
-          sf->dict = NULL;
-          sf->writer = NULL;
         }
-
+      else
+        {
+          casewriter_destroy (sf->writer);
+          dict_unref (sf->dict);
+        }
       fh_unref (sf->file);
       string_array_destroy (&sf->variables);
       matrix_expr_destroy (sf->names);
       stringi_set_destroy (&sf->strings);
-      casewriter_destroy (sf->writer);
-      dict_unref (sf->dict);
       free (sf);
     }
 }
@@ -4633,8 +4633,6 @@ matrix_parse_save (struct matrix_state *s)
     }
 
   save->sf = save_file_create (s, fh, &variables, names, &strings);
-  fh = NULL;
-
   return cmd;
 
 error: