diff options
author | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2004-05-03 16:11:13 +0000 |
---|---|---|
committer | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2004-05-03 16:11:13 +0000 |
commit | 2a7b18f2bab26331de1fadfcabc35d95997f95c6 (patch) | |
tree | 9818249ef7ffbca627af7f7ee5769bba35f9e817 | |
parent | 9d2f5abcebef64c020ce39a5285d3e9f73486514 (diff) |
Give error when trying to treat a non-array parameter as an array parameter.
Fixes PR Cactus/1607.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@3684 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r-- | src/main/Parameters.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main/Parameters.c b/src/main/Parameters.c index 7db92017..42373e04 100644 --- a/src/main/Parameters.c +++ b/src/main/Parameters.c @@ -1110,8 +1110,10 @@ static t_param *ParameterFind (const char *name, char *basename; int array_index; + /* Split an array parameter into its name and index */ GetBaseName(name, &basename, &array_index); + /* Find the parameter */ node = ParameterPTreeNodeFind (paramtree, basename); free(basename); @@ -1120,6 +1122,7 @@ static t_param *ParameterFind (const char *name, if (node) { + /* Parameter exists for some thorn; check thorn */ for (list = node->paramlist; list; list = list->next) { if (! thorn) @@ -1144,21 +1147,30 @@ static t_param *ParameterFind (const char *name, } } + /* Now get the correct parameter structure */ if(list) { - if(list->param->array && array_index > -1) + if(!list->param->array && array_index > -1) { + /* Trying to treat a non-array parameter as an array */ + retval = NULL; + } + else if(list->param->array && array_index > -1) + { + /* It's an array parameter */ if(array_index < list->param->props->array_size) { retval = &(list->param->array[array_index]); } else { + /* It's out of bounds */ retval = NULL; } } else { + /* Just a normal parameter */ retval = list->param; } } |