src/java.base/share/native/libfdlibm/k_rem_pio2.c

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -250,11 +250,11 @@
     /* check if recomputation is needed */
         if(z==zero) {
             j = 0;
             for (i=jz-1;i>=jk;i--) j |= iq[i];
             if(j==0) { /* need recomputation */
-                for(k=1;iq[jk-k]==0;k++);   /* k = no. of terms needed */
+                for(k=1;k<=jk&&iq[jk-k]==0;k++);   /* k = no. of terms needed */
 
                 for(i=jz+1;i<=jz+k;i++) {   /* add q[jz+1] to q[jz+k] */
                     f[jx+i] = (double) ipio2[jv+i];
                     for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
                     q[i] = fw;