From: stevenj Date: Wed, 7 Jul 2010 23:10:33 +0000 (-0400) Subject: yikes, fix argument check for tol argument in add_constraint functions X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=1df7dfe4c2242b25b15806b22525ef76317c3c6b;p=nlopt.git yikes, fix argument check for tol argument in add_constraint functions darcs-hash:20100707231033-c8de0-d1d4a50c4e1ac45220449d5b0057a758b9441dff.gz --- 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;