You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (Resolved) (JIRA)" <xe...@xml.apache.org> on 2012/02/13 14:14:59 UTC
[jira] [Resolved] (XERCESJ-1549) An incomplete fix for the NPE bugs
in XSSimpleTypeDecl.java
[ https://issues.apache.org/jira/browse/XERCESJ-1549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Glavassevich resolved XERCESJ-1549.
-------------------------------------------
Resolution: Invalid
If a type has an enumeration facet, fEnumeration will not be null.
> An incomplete fix for the NPE bugs in XSSimpleTypeDecl.java
> -----------------------------------------------------------
>
> Key: XERCESJ-1549
> URL: https://issues.apache.org/jira/browse/XERCESJ-1549
> Project: Xerces2-J
> Issue Type: Bug
> Reporter: Guangtai Liang
> Priority: Critical
> Labels: incomplete_fix, missing_fixes
> Original Estimate: 10m
> Remaining Estimate: 10m
>
> The fix revision 318723 was aimed to remove an NPE bug on the "fEnumeration" in the method "getLexicalEnumerations" of the file "/xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java" , but it is incomplete.
> Since the "fEnumeration" is an class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods (e.g., Line 1311 in the method "checkFacets").
> The buggy code the proposed missing fixes should be made in is copied as bellowing:
> private void checkFacets(ValidatedInfo validatedInfo) throws InvalidDatatypeValueException {
> Object ob = validatedInfo.actualValue;
> String content = validatedInfo.normalizedValue;
> int length = fDVs[fValidationDV].getDataLength(ob);
> // maxLength
> if ( (fFacetsDefined & FACET_MAXLENGTH) != 0 ) {
> if ( length > fMaxLength ) {
> throw new InvalidDatatypeValueException("cvc-maxLength-valid",
> new Object[]{content, Integer.toString(length), Integer.toString(fMaxLength)});
> }
> }
> //minLength
> if ( (fFacetsDefined & FACET_MINLENGTH) != 0 ) {
> if ( length < fMinLength ) {
> throw new InvalidDatatypeValueException("cvc-minLength-valid",
> new Object[]{content, Integer.toString(length), Integer.toString(fMinLength)});
> }
> }
> //length
> if ( (fFacetsDefined & FACET_LENGTH) != 0 ) {
> if ( length != fLength ) {
> throw new InvalidDatatypeValueException("cvc-length-valid",
> new Object[]{content, Integer.toString(length), Integer.toString(fLength)});
> }
> }
> //enumeration
> if ( ((fFacetsDefined & FACET_ENUMERATION) != 0 ) ) {
> boolean present = false;
> [Line 1311] for (int i = 0; i < fEnumeration.size(); i++) {
> [Line 1312] if (isEqual(ob, fEnumeration.elementAt(i))) {
> present = true;
> break;
> }
> }
> if(!present){
> throw new InvalidDatatypeValueException("cvc-enumeration-valid",
> new Object [] {content, fEnumeration.toString()});
> }
> }
> //fractionDigits
> if ((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) {
> int scale = fDVs[fValidationDV].getFractionDigits(ob);
> if (scale > fFractionDigits) {
> throw new InvalidDatatypeValueException("cvc-fractionDigits-valid",
> new Object[] {content, Integer.toString(scale), Integer.toString(fFractionDigits)});
> }
> }
> //totalDigits
> if ((fFacetsDefined & FACET_TOTALDIGITS)!=0) {
> int totalDigits = fDVs[fValidationDV].getTotalDigits(ob);
> if (totalDigits > fTotalDigits) {
> throw new InvalidDatatypeValueException("cvc-totalDigits-valid",
> new Object[] {content, Integer.toString(totalDigits), Integer.toString(fTotalDigits)});
> }
> }
> int compare;
> //maxinclusive
> if ( (fFacetsDefined & FACET_MAXINCLUSIVE) != 0 ) {
> compare = fDVs[fValidationDV].compare(ob, fMaxInclusive);
> if (compare != -1 && compare != 0) {
> throw new InvalidDatatypeValueException("cvc-maxInclusive-valid",
> new Object[] {content, fMaxInclusive});
> }
> }
> //maxExclusive
> if ( (fFacetsDefined & FACET_MAXEXCLUSIVE) != 0 ) {
> compare = fDVs[fValidationDV].compare(ob, fMaxExclusive );
> if (compare != -1) {
> throw new InvalidDatatypeValueException("cvc-maxExclusive-valid",
> new Object[] {content, fMaxExclusive});
> }
> }
> //minInclusive
> if ( (fFacetsDefined & FACET_MININCLUSIVE) != 0 ) {
> compare = fDVs[fValidationDV].compare(ob, fMinInclusive);
> if (compare != 1 && compare != 0) {
> throw new InvalidDatatypeValueException("cvc-minInclusive-valid",
> new Object[] {content, fMinInclusive});
> }
> }
> //minExclusive
> if ( (fFacetsDefined & FACET_MINEXCLUSIVE) != 0 ) {
> compare = fDVs[fValidationDV].compare(ob, fMinExclusive);
> if (compare != 1) {
> throw new InvalidDatatypeValueException("cvc-minExclusive-valid",
> new Object[] {content, fMinExclusive});
> }
> }
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org