From 4dc114acc25c2ac29aab6e05a78a444341fa39ae Mon Sep 17 00:00:00 2001 From: erg Date: Mon, 28 Apr 2008 16:52:59 +0000 Subject: [PATCH] Fix bug in vpsc code where a divide by 0 may occur --- lib/neatogen/quad_prog_vpsc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/neatogen/quad_prog_vpsc.c b/lib/neatogen/quad_prog_vpsc.c index b6f6256b9..46c66f59f 100644 --- a/lib/neatogen/quad_prog_vpsc.c +++ b/lib/neatogen/quad_prog_vpsc.c @@ -143,7 +143,10 @@ constrained_majorization_vpsc(CMajEnvVPSC * e, float *b, float *place, } denominator += r * d[i]; } - beta = numerator / denominator; + if (denominator != 0.0) + beta = numerator / denominator; + else + beta = 1.0; for (i = 0; i < n; i++) { /* beta > 1.0 takes us back outside the feasible region -- 2.40.0