Project

Profile

Help

Bug #3212

closed

NullPointerException evaluating if (A = B to C)

Added by Michael Kay about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XPath conformance
Sprint/Milestone:
-
Start date:
2017-04-28
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
9.7, trunk
Fixed in Maintenance Release:
Platforms:

Description

A stylesheet contains the logic

<xsl:variable name="range" select="f:eval(@a) to f:eval(@b)"/>
<xsl:if test="f:eval(X) = $range">...</xsl:if>

Saxon successfully identifies the opportunity to turn this into an IntegerRangeTest (A = B to C) which is evaluated essentially as (A>=B and A<=C).

However, it seems that the optimized code fails to take account of the fact that f:eval() is capable of returning an empty sequence, in which case the boolean expression should evaluate to false.

This code has been in the product for a long time!

Actions #1

Updated by Michael Kay about 7 years ago

Reproduced by this simple test case (added to W3C as math-0107)

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:f="http://local.functions/" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="#all">

  <!-- Simulate Saxon bug 3212 -->

  <xsl:function name="f:parseInt" as="xs:integer?">
    <xsl:param name="in" as="xs:string?"/>
    <xsl:sequence select="xs:integer($in)"/>
  </xsl:function>

  <xsl:template match="/">
    <out>
      <xsl:variable name="range" select="f:parseInt(()) to f:parseInt('123')"/>
      <xsl:if test="42 = $range">
        <matched/>
      </xsl:if>
    </out>
  </xsl:template>
</xsl:stylesheet>

Actions #2

Updated by Michael Kay about 7 years ago

  • Status changed from New to Resolved
  • Fix Committed on Branch 9.7, 9.8 added

Patch committed for 9.7 and 9.8. Confirmed that the bug has been in the code since at least 9.3 and probably much longer.

Actions #3

Updated by O'Neil Delpratt almost 7 years ago

  • Fix Committed on Branch trunk added
  • Fix Committed on Branch deleted (9.8)
Actions #4

Updated by O'Neil Delpratt almost 7 years ago

  • Applies to branch deleted (9.8)
Actions #5

Updated by O'Neil Delpratt almost 7 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.7.0.19 added

Bug fix applied in the 9.7.0.19 maintenance release.

Please register to edit this issue

Also available in: Atom PDF