You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2007/01/31 16:19:29 UTC
svn commit: r501862 -
/xerces/c/branches/xerces-2.7/src/xercesc/validators/common/AllContentModel.cpp
Author: amassari
Date: Wed Jan 31 07:19:28 2007
New Revision: 501862
URL: http://svn.apache.org/viewvc?view=rev&rev=501862
Log:
Before using a local memory manager, check that we have a valid pointer
Modified:
xerces/c/branches/xerces-2.7/src/xercesc/validators/common/AllContentModel.cpp
Modified: xerces/c/branches/xerces-2.7/src/xercesc/validators/common/AllContentModel.cpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-2.7/src/xercesc/validators/common/AllContentModel.cpp?view=diff&rev=501862&r1=501861&r2=501862
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/validators/common/AllContentModel.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/validators/common/AllContentModel.cpp Wed Jan 31 07:19:28 2007
@@ -113,57 +113,59 @@
if (childCount == 0 && (fHasOptionalContent || !fNumRequired))
return -1;
- MemoryManager* const localMemoryManager =
- children[0]->getMemoryManager();
-
- // Check for duplicate element
- bool* elementSeen = (bool*) localMemoryManager->allocate(fCount*sizeof(bool)); //new bool[fCount];
-
- const ArrayJanitor<bool> jan(elementSeen, localMemoryManager);
-
- // initialize the array
- for (unsigned int i = 0; i < fCount; i++)
- elementSeen[i] = false;
-
// keep track of the required element seen
unsigned int numRequiredSeen = 0;
- for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) {
- // Get the current child out of the source index
- const QName* curChild = children[outIndex];
-
- // If it's PCDATA, then we just accept that
- if (fIsMixed && curChild->getURI() == XMLElementDecl::fgPCDataElemId)
- continue;
-
- // And try to find it in our list
- unsigned int inIndex = 0;
- for (; inIndex < fCount; inIndex++)
- {
- const QName* inChild = fChildren[inIndex];
- if ((inChild->getURI() == curChild->getURI()) &&
- (XMLString::equals(inChild->getLocalPart(), curChild->getLocalPart()))) {
- // found it
- // If this element was seen already, indicate an error was
- // found at the duplicate index.
- if (elementSeen[inIndex]) {
- return outIndex;
- }
- else
- elementSeen[inIndex] = true;
+ if(childCount > 0)
+ {
+ MemoryManager* const localMemoryManager = children[0]->getMemoryManager();
+
+ // Check for duplicate element
+ bool* elementSeen = (bool*) localMemoryManager->allocate(fCount*sizeof(bool)); //new bool[fCount];
+
+ const ArrayJanitor<bool> jan(elementSeen, localMemoryManager);
+
+ // initialize the array
+ for (unsigned int i = 0; i < fCount; i++)
+ elementSeen[i] = false;
+
+ for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) {
+ // Get the current child out of the source index
+ const QName* curChild = children[outIndex];
+
+ // If it's PCDATA, then we just accept that
+ if (fIsMixed && curChild->getURI() == XMLElementDecl::fgPCDataElemId)
+ continue;
+
+ // And try to find it in our list
+ unsigned int inIndex = 0;
+ for (; inIndex < fCount; inIndex++)
+ {
+ const QName* inChild = fChildren[inIndex];
+ if ((inChild->getURI() == curChild->getURI()) &&
+ (XMLString::equals(inChild->getLocalPart(), curChild->getLocalPart()))) {
+ // found it
+ // If this element was seen already, indicate an error was
+ // found at the duplicate index.
+ if (elementSeen[inIndex]) {
+ return outIndex;
+ }
+ else
+ elementSeen[inIndex] = true;
- if (!fChildOptional[inIndex])
- numRequiredSeen++;
+ if (!fChildOptional[inIndex])
+ numRequiredSeen++;
- break;
+ break;
+ }
}
- }
- // We did not find this one, so the validation failed
- if (inIndex == fCount) {
- return outIndex;
- }
+ // We did not find this one, so the validation failed
+ if (inIndex == fCount) {
+ return outIndex;
+ }
+ }
}
// Were all the required elements of the <all> encountered?
@@ -182,64 +184,65 @@
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool) const
{
-
- SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool);
-
// If <all> had minOccurs of zero and there are
// no children to validate, trivially validate
if (childCount == 0 && (fHasOptionalContent || !fNumRequired))
return -1;
- MemoryManager* const localMemoryManager =
- children[0]->getMemoryManager();
-
- // Check for duplicate element
- bool* elementSeen = (bool*) localMemoryManager->allocate(fCount*sizeof(bool)); //new bool[fCount];
-
- const ArrayJanitor<bool> jan(elementSeen, localMemoryManager);
-
- // initialize the array
- for (unsigned int i = 0; i < fCount; i++)
- elementSeen[i] = false;
-
// keep track of the required element seen
unsigned int numRequiredSeen = 0;
- for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) {
- // Get the current child out of the source index
- QName* const curChild = children[outIndex];
-
- // If it's PCDATA, then we just accept that
- if (fIsMixed && curChild->getURI() == XMLElementDecl::fgPCDataElemId)
- continue;
-
- // And try to find it in our list
- unsigned int inIndex = 0;
- for (; inIndex < fCount; inIndex++)
- {
- QName* const inChild = fChildren[inIndex];
- if ( comparator.isEquivalentTo(curChild, inChild)) {
- // match
- // If this element was seen already, indicate an error was
- // found at the duplicate index.
- if (elementSeen[inIndex]) {
- return outIndex;
- }
- else
- elementSeen[inIndex] = true;
+ if(childCount > 0)
+ {
+ SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool);
+
+ MemoryManager* const localMemoryManager = children[0]->getMemoryManager();
+
+ // Check for duplicate element
+ bool* elementSeen = (bool*) localMemoryManager->allocate(fCount*sizeof(bool)); //new bool[fCount];
+
+ const ArrayJanitor<bool> jan(elementSeen, localMemoryManager);
+
+ // initialize the array
+ for (unsigned int i = 0; i < fCount; i++)
+ elementSeen[i] = false;
+
+ for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) {
+ // Get the current child out of the source index
+ QName* const curChild = children[outIndex];
+
+ // If it's PCDATA, then we just accept that
+ if (fIsMixed && curChild->getURI() == XMLElementDecl::fgPCDataElemId)
+ continue;
+
+ // And try to find it in our list
+ unsigned int inIndex = 0;
+ for (; inIndex < fCount; inIndex++)
+ {
+ QName* const inChild = fChildren[inIndex];
+ if ( comparator.isEquivalentTo(curChild, inChild)) {
+ // match
+ // If this element was seen already, indicate an error was
+ // found at the duplicate index.
+ if (elementSeen[inIndex]) {
+ return outIndex;
+ }
+ else
+ elementSeen[inIndex] = true;
- if (!fChildOptional[inIndex])
- numRequiredSeen++;
+ if (!fChildOptional[inIndex])
+ numRequiredSeen++;
- break;
+ break;
+ }
}
- }
- // We did not find this one, so the validation failed
- if (inIndex == fCount) {
- return outIndex;
- }
+ // We did not find this one, so the validation failed
+ if (inIndex == fCount) {
+ return outIndex;
+ }
+ }
}
// Were all the required elements of the <all> encountered?
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org