diff options
author | Edward Hervey <bilboed@bilboed.com> | 2014-04-11 16:03:16 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2014-04-11 16:06:05 +0200 |
commit | 9070fc8fc31f421a0137af92aa3712a17cc93642 (patch) | |
tree | c3120c4007fb35fb1742fb28b3ccf9db9ab6e435 | |
parent | 0df464556928237e816cee74899be57af4ae1a92 (diff) | |
download | orc-9070fc8fc31f421a0137af92aa3712a17cc93642.tar.gz |
orcexecutor: Don't use negative values on arrays
orc_program_find_var_by_name() can return -1 on errors, if that
happens, don't try to read/write in random memory :)
CID #1146974
CID #1146975
CID #1146976
-rw-r--r-- | orc/orcexecutor.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/orc/orcexecutor.c b/orc/orcexecutor.c index 96a7fc9..6fe296d 100644 --- a/orc/orcexecutor.c +++ b/orc/orcexecutor.c @@ -102,7 +102,8 @@ orc_executor_set_array_str (OrcExecutor *ex, const char *name, void *ptr) { int var; var = orc_program_find_var_by_name (ex->program, name); - ex->arrays[var] = ptr; + if (var >= 0) + ex->arrays[var] = ptr; } void @@ -142,7 +143,8 @@ orc_executor_set_param_str (OrcExecutor *ex, const char *name, int value) { int var; var = orc_program_find_var_by_name (ex->program, name); - ex->params[var] = value; + if (var >= 0) + ex->params[var] = value; } int @@ -156,7 +158,9 @@ orc_executor_get_accumulator_str (OrcExecutor *ex, const char *name) { int var; var = orc_program_find_var_by_name (ex->program, name); - return ex->accumulators[var]; + if (var >= 0) + return ex->accumulators[var]; + return -1; } void |