From 1df7dfe4c2242b25b15806b22525ef76317c3c6b Mon Sep 17 00:00:00 2001 From: stevenj Date: Wed, 7 Jul 2010 19:10:33 -0400 Subject: [PATCH] yikes, fix argument check for tol argument in add_constraint functions darcs-hash:20100707231033-c8de0-d1d4a50c4e1ac45220449d5b0057a758b9441dff.gz --- api/options.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/options.c b/api/options.c index db955cc..9b2beda 100644 --- 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; -- 2.30.2