[ 
https://issues.apache.org/jira/browse/XERCESC-1993?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Gmelin resolved XERCESC-1993.
-------------------------------------

    Resolution: Duplicate

Duplicate of XERCESC-1994, sorry
                
> ContentSpecNode::getMaxTotalRange: Operator precedence flaw
> -----------------------------------------------------------
>
>                 Key: XERCESC-1993
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1993
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (XML Schema)
>    Affects Versions: 3.1.1
>         Environment: Not relevant, C++ syntax problem
>            Reporter: Michael Gmelin
>              Labels: patch
>         Attachments: ContentSpecNode.cpp.patch
>
>   Original Estimate: 5m
>  Remaining Estimate: 5m
>
> 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);
> Patch:
> --- a/src/xercesc/validators/common/ContentSpecNode.cpp
> +++ b/src/xercesc/validators/common/ContentSpecNode.cpp
> @@ -259,7 +259,7 @@ int ContentSpecNode::getMaxTotalRange() const {
>              else {
>  
>                  if ((fType & 0x0f) == ContentSpecNode::Choice) {
> -                    max = max * (maxFirst > maxSecond) ? maxFirst : 
> maxSecond;
> +                    max = max * ((maxFirst > maxSecond) ? maxFirst : 
> maxSecond);
>                  }
>                  else {
>                      max = max * (maxFirst + maxSecond);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to