chiark
/
gitweb
/
~ianmdlvl
/
nlopt.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0cb3813
)
yikes, fix argument check for tol argument in add_constraint functions
author
stevenj
<stevenj@alum.mit.edu>
Wed, 7 Jul 2010 23:10:33 +0000
(19:10 -0400)
committer
stevenj
<stevenj@alum.mit.edu>
Wed, 7 Jul 2010 23:10:33 +0000
(19:10 -0400)
darcs-hash:
20100707231033
-c8de0-
d1d4a50c4e1ac45220449d5b0057a758b9441dff
.gz
api/options.c
patch
|
blob
|
history
diff --git
a/api/options.c
b/api/options.c
index db955ccea63a6a2dc16c98d6717cdd31b5f0f729..9b2bedaf19c02ab2084ffc0c32dde900c86c5401 100644
(file)
--- a/
api/options.c
+++ b/
api/options.c
@@
-336,9
+336,11
@@
static nlopt_result add_constraint(unsigned *m, unsigned *m_alloc,
const double *tol)
{
double *tolcopy;
+ unsigned i;
- if ((fc && mfc) || (fc && fm != 1) || (!fc && !mfc) ||
tol < 0
)
+ if ((fc && mfc) || (fc && fm != 1) || (!fc && !mfc) ||
!tol
)
return NLOPT_INVALID_ARGS;
+ for (i = 0; i < fm; ++i) if (tol[i] < 0) return NLOPT_INVALID_ARGS;
tolcopy = (double *) malloc(sizeof(double) * fm);
if (fm && !tolcopy) return NLOPT_OUT_OF_MEMORY;