From 3c9f92b3918a452eca529d88db73a0a140b26dbb Mon Sep 17 00:00:00 2001 From: "Chuvelev, Michael" Date: Fri, 19 Sep 2025 09:24:38 -0700 Subject: [PATCH] Prevent csrscl/zdrscl from going to infinite loop on Infinity input --- SRC/csrscl.f | 6 ++++++ SRC/zdrscl.f | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/SRC/csrscl.f b/SRC/csrscl.f index 02ebc1832..3eb059a45 100644 --- a/SRC/csrscl.f +++ b/SRC/csrscl.f @@ -112,6 +112,7 @@ SUBROUTINE CSRSCL( N, SA, SX, INCX ) * .. * .. Intrinsic Functions .. INTRINSIC ABS + INTRINSIC HUGE * .. * .. Executable Statements .. * @@ -119,6 +120,11 @@ SUBROUTINE CSRSCL( N, SA, SX, INCX ) * IF( N.LE.0 ) $ RETURN +* + IF( SA.GT.HUGE(SA) .OR. SA.LT.-HUGE(SA) ) THEN + CALL CSSCAL( N, SA, SX, INCX ) + RETURN + END IF * * Get machine parameters * diff --git a/SRC/zdrscl.f b/SRC/zdrscl.f index a608cc40c..6fc1830c8 100644 --- a/SRC/zdrscl.f +++ b/SRC/zdrscl.f @@ -112,6 +112,7 @@ SUBROUTINE ZDRSCL( N, SA, SX, INCX ) * .. * .. Intrinsic Functions .. INTRINSIC ABS + INTRINSIC HUGE * .. * .. Executable Statements .. * @@ -119,6 +120,11 @@ SUBROUTINE ZDRSCL( N, SA, SX, INCX ) * IF( N.LE.0 ) $ RETURN +* + IF( SA.GT.HUGE(SA) .OR. SA.LT.-HUGE(SA) ) THEN + CALL ZDSCAL( N, SA, SX, INCX ) + RETURN + END IF * * Get machine parameters *