From ca89a16a7246e1226509e5351583070baec02182 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Fri, 24 Mar 2017 15:49:55 +0100 Subject: [PATCH] Fix integer overflow in threshold calculation Related to lapack issue 135, the threshold calculation can overflow as well as the multiplication is evaluated from left to right. Without explicit parentheses, the calculation would overflow for N >= 18919 --- lapack-netlib/SRC/dbdsqr.f | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lapack-netlib/SRC/dbdsqr.f b/lapack-netlib/SRC/dbdsqr.f index 176823b64..41519227b 100644 --- a/lapack-netlib/SRC/dbdsqr.f +++ b/lapack-netlib/SRC/dbdsqr.f @@ -410,12 +410,12 @@ 40 CONTINUE 50 CONTINUE SMINOA = SMINOA / SQRT( DBLE( N ) ) - THRESH = MAX( TOL*SMINOA, MAXITR*N*N*UNFL ) + THRESH = MAX( TOL*SMINOA, MAXITR*(N*(N*UNFL)) ) ELSE * * Absolute accuracy desired * - THRESH = MAX( ABS( TOL )*SMAX, MAXITR*N*N*UNFL ) + THRESH = MAX( ABS( TOL )*SMAX, MAXITR*(N*(N*UNFL)) ) END IF * * Prepare for main iteration loop for the singular values @@ -446,7 +446,7 @@ ITERDIVN = ITERDIVN + 1 IF (ITERDIVN.GE.MAXITDIVN ) $ GO TO 200 - ENDIF + END IF * * Find diagonal block of matrix to work on *