Fix bug 22419
[pspp-builds.git] / src / language / data-io / get.c
index b861aca52ffef7df758d3eabfc506718795081eb..f8a84b142919d59d43f31222bf42c45fdb747b8d 100644 (file)
@@ -45,8 +45,6 @@
 #include <libpspp/str.h>
 #include <libpspp/taint.h>
 
-#include "get-data.h"
-
 #include "xalloc.h"
 
 #include "gettext.h"
@@ -75,11 +73,6 @@ parse_read_command (struct lexer *lexer, struct dataset *ds, enum reader_command
   struct dictionary *dict = NULL;
   struct case_map *map = NULL;
 
-  if ( type == GET_CMD && lex_match_id (lexer, "DATA") )
-    {
-      return parse_get_data_command (lexer, ds);
-    }
-
   for (;;)
     {
       lex_match (lexer, '/');
@@ -88,6 +81,7 @@ parse_read_command (struct lexer *lexer, struct dataset *ds, enum reader_command
        {
          lex_match (lexer, '=');
 
+          fh_unref (fh);
          fh = fh_parse (lexer, FH_REF_FILE | FH_REF_SCRATCH);
          if (fh == NULL)
             goto error;
@@ -140,9 +134,11 @@ parse_read_command (struct lexer *lexer, struct dataset *ds, enum reader_command
 
   proc_set_active_file (ds, reader, dict);
 
+  fh_unref (fh);
   return CMD_SUCCESS;
 
  error:
+  fh_unref (fh);
   casereader_destroy (reader);
   if (dict != NULL)
     dict_destroy (dict);
@@ -368,9 +364,11 @@ parse_write_command (struct lexer *lexer, struct dataset *ds,
                                            map);
   dict_destroy (dict);
 
+  fh_unref (handle);
   return writer;
 
  error:
+  fh_unref (handle);
   casewriter_destroy (writer);
   dict_destroy (dict);
   case_map_destroy (map);
@@ -730,8 +728,8 @@ cmd_match_files (struct lexer *lexer, struct dataset *ds)
   bool saw_in = false;
   struct casereader *active_file = NULL;
 
-  char first_name[LONG_NAME_LEN + 1] = "";
-  char last_name[LONG_NAME_LEN + 1] = "";
+  char first_name[VAR_NAME_LEN + 1] = "";
+  char last_name[VAR_NAME_LEN + 1] = "";
 
   struct taint *taint = NULL;
 
@@ -1089,6 +1087,7 @@ mtf_close_all_files (struct mtf_proc *mtf)
 
   ll_for_each_preremove (file, struct mtf_file, ll, &mtf->files)
     {
+      fh_unref (file->handle);
       casereader_destroy (file->reader);
       free (file->by);
       dict_destroy (file->dict);