sys-file-reader: Check that multiple response set names begin with `$'.
[pspp] / src / data / sys-file-reader.c
index c9c843dfaf4dd83cee88f7dd510284fa37e516a7..898b6739475b3fedc2e5ae29855747997a3d34f0 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -1047,6 +1047,13 @@ read_mrsets (struct sfm_reader *r, size_t size, size_t count,
         break;
       mrset->name = xstrdup (name);
 
+      if (mrset->name[0] != '$')
+        {
+          sys_warn (r, _("`%s' does not begin with `$' at offset %zu "
+                         "in MRSETS record."), mrset->name, text_pos (text));
+          break;
+        }
+
       if (text_match (text, 'C'))
         {
           mrset->type = MRSET_MC;
@@ -1766,11 +1773,11 @@ sys_file_casereader_read (struct casereader *reader, void *r_)
   return c;
 
 eof:
-  case_unref (c);
   if (i != 0)
     partial_record (r);
   if (r->case_cnt != -1)
     read_error (reader, r);
+  case_unref (c);
   return NULL;
 }