Skip to content

Commit 3c9f92b

Browse files
Prevent csrscl/zdrscl from going to infinite loop on Infinity input
1 parent 6b92a7a commit 3c9f92b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

SRC/csrscl.f

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,19 @@ SUBROUTINE CSRSCL( N, SA, SX, INCX )
112112
* ..
113113
* .. Intrinsic Functions ..
114114
INTRINSIC ABS
115+
INTRINSIC HUGE
115116
* ..
116117
* .. Executable Statements ..
117118
*
118119
* Quick return if possible
119120
*
120121
IF( N.LE.0 )
121122
$ RETURN
123+
*
124+
IF( SA.GT.HUGE(SA) .OR. SA.LT.-HUGE(SA) ) THEN
125+
CALL CSSCAL( N, SA, SX, INCX )
126+
RETURN
127+
END IF
122128
*
123129
* Get machine parameters
124130
*

SRC/zdrscl.f

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,19 @@ SUBROUTINE ZDRSCL( N, SA, SX, INCX )
112112
* ..
113113
* .. Intrinsic Functions ..
114114
INTRINSIC ABS
115+
INTRINSIC HUGE
115116
* ..
116117
* .. Executable Statements ..
117118
*
118119
* Quick return if possible
119120
*
120121
IF( N.LE.0 )
121122
$ RETURN
123+
*
124+
IF( SA.GT.HUGE(SA) .OR. SA.LT.-HUGE(SA) ) THEN
125+
CALL ZDSCAL( N, SA, SX, INCX )
126+
RETURN
127+
END IF
122128
*
123129
* Get machine parameters
124130
*

0 commit comments

Comments
 (0)