diff src/ov-struct.cc @ 6811:3fe394f8502b

[project @ 2007-08-10 19:07:34 by jwe]
author jwe
date Fri, 10 Aug 2007 19:07:35 +0000
parents 2aad75fcc93a
children e8a18d380097
line wrap: on
line diff
--- a/src/ov-struct.cc	Fri Aug 10 18:53:49 2007 +0000
+++ b/src/ov-struct.cc	Fri Aug 10 19:07:35 2007 +0000
@@ -35,6 +35,7 @@
 #include "ov-list.h"
 #include "ov-struct.h"
 #include "unwind-prot.h"
+#include "utils.h"
 #include "variables.h"
 
 #include "Array-util.h"
@@ -616,6 +617,12 @@
       if (error_state)
 	return retval;
 
+      if (! valid_identifier (key))
+	{
+	  error ("struct: invalid structure field name `%s'", key.c_str ());
+	  return retval;
+	}
+
       // Value may be v, { v }, or { v1, v2, ... }
       // In the first two cases, we need to create a cell array of
       // the appropriate dimensions filled with v.  In the last case, 
@@ -941,6 +948,13 @@
 				return retval;
 			    }
 
+			  if (! valid_identifier (field_str))
+			    {
+			      error ("cell2struct: invalid field name `%s'",
+				     field_str.c_str ());
+			      break;
+			    }
+
 			  map.reshape (value_dv);
 
 			  map.assign (field_str, c_value);