Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-1994

ContentSpecNode::getMaxTotalRange: Operator precedence flaw

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.1
    • Fix Version/s: 3.1.2, 3.2.0
    • Labels:
      None
    • Environment:
      Not relevant, C++ syntax problem

      Description

      ContentSpecType.cpp says at about line 260:

      if ((fType & 0x0f) == ContentSpecNode::Choice)

      { max = max * (maxFirst > maxSecond) ? maxFirst : maxSecond; }

      Thanks to operator precedence max evaluates either to maxFirst or maxSecond, but never to max*maxFirst or max*maxSecond.

      Adding parenthesis makes this do the right thing:
      max = max * ((maxFirst > maxSecond) ? maxFirst : maxSecond);

        Attachments

          Activity

            People

            • Assignee:
              amassari Alberto Massari
              Reporter:
              grembo Michael Gmelin
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: