8062923: XSL: Run-time internal error in 'substring()'
8062924: XSL: wrong answer from substring() function
Reviewed-by: joehw
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Wed Jul 05 20:16:23 2017 +0200
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Mon Jan 26 12:17:59 2015 +0300
@@ -270,8 +270,8 @@
if (Double.isNaN(start))
return(EMPTYSTRING);
- final int strlen = value.length();
- int istart = (int)Math.round(start) - 1;
+ final int strlen = value.length();
+ int istart = (int)Math.round(start) - 1;
if (istart > strlen)
return(EMPTYSTRING);
@@ -292,10 +292,11 @@
public static String substringF(String value, double start, double length) {
if (Double.isInfinite(start) ||
Double.isNaN(start) ||
- Double.isNaN(length))
+ Double.isNaN(length) ||
+ length < 0)
return(EMPTYSTRING);
- int istart = (int)Math.round(start) - 1;
+ int istart = (int)Math.round(start) - 1;
final int isum;
if (Double.isInfinite(length))
isum = Integer.MAX_VALUE;