Fix potential crash if matrix file variables are of unexpected types
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 16 May 2017 12:00:39 +0000 (14:00 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 16 May 2017 16:06:06 +0000 (18:06 +0200)
src/language/data-io/matrix-reader.c

index 284ec6f9316cf192a98cf0e4bb50b5c1e8d3ede4..afeffe54dab41c697809b30943a9f043cdfb4ec8 100644 (file)
@@ -103,6 +103,14 @@ create_matrix_reader_from_case_reader (const struct dictionary *dict, struct cas
       return NULL;
     }
 
+  if (!var_is_alpha (mr->varname))
+    {
+      msg (ME, _("Matrix dataset variable %s should be of string type."),
+          "VARNAME_");
+      free (mr);
+      return NULL;
+    }
+
   mr->rowtype = dict_lookup_var (dict, "rowtype_");
   if (mr->rowtype == NULL)
     {
@@ -111,6 +119,14 @@ create_matrix_reader_from_case_reader (const struct dictionary *dict, struct cas
       return NULL;
     }
 
+  if (!var_is_alpha (mr->rowtype))
+    {
+      msg (ME, _("Matrix dataset variable %s should be of string type."),
+          "ROWTYPE_");
+      free (mr);
+      return NULL;
+    }
+
   size_t dvarcnt;
   const struct variable **dvars = NULL;
   dict_get_vars (dict, &dvars, &dvarcnt, DC_SCRATCH);