From 6c362032c22fe91b1c643744e4d6ed4589da505c Mon Sep 17 00:00:00 2001 From: Neil Graham <neilg@apache.org> Date: Mon, 1 Dec 2003 20:41:25 +0000 Subject: [PATCH] fix for infinite loop between XSComplexTypeDefinitions and XSElementDeclarations; from David Cargill git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@175502 13f79535-47bb-0310-9956-ffa450edef68 --- .../framework/psvi/XSElementDeclaration.hpp | 9 +++++++++ src/xercesc/internal/XSObjectFactory.cpp | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/xercesc/framework/psvi/XSElementDeclaration.hpp b/src/xercesc/framework/psvi/XSElementDeclaration.hpp index 22482fcd7..08550f5fd 100644 --- a/src/xercesc/framework/psvi/XSElementDeclaration.hpp +++ b/src/xercesc/framework/psvi/XSElementDeclaration.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/01 20:41:25 neilg + * fix for infinite loop between XSComplexTypeDefinitions and XSElementDeclarations; from David Cargill + * * Revision 1.6 2003/11/23 16:20:16 knoaman * PSVI: pass scope and enclosing type during construction. * @@ -285,6 +288,8 @@ public: */ void setId(unsigned int id); + void setTypeDefinition(XSTypeDefinition* typeDefinition); + //@} private: @@ -356,6 +361,10 @@ inline XSComplexTypeDefinition *XSElementDeclaration::getEnclosingCTDefinition() return fEnclosingTypeDefinition; } +inline void XSElementDeclaration::setTypeDefinition(XSTypeDefinition* typeDefinition) +{ + fTypeDefinition = typeDefinition; +} XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/internal/XSObjectFactory.cpp b/src/xercesc/internal/XSObjectFactory.cpp index e114b06ad..60864fc11 100644 --- a/src/xercesc/internal/XSObjectFactory.cpp +++ b/src/xercesc/internal/XSObjectFactory.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/12/01 20:41:25 neilg + * fix for infinite loop between XSComplexTypeDefinitions and XSElementDeclarations; from David Cargill + * * Revision 1.7 2003/11/27 16:42:00 neilg * fixes for segfaults and infinite loops in schema component model implementation; thanks to David Cargill * @@ -434,9 +437,9 @@ XSObjectFactory::addOrFind(SchemaElementDecl* const elemDecl, if (elemDecl->getSubstitutionGroupElem()) xsSubElem = addOrFind(elemDecl->getSubstitutionGroupElem(), xsModel); - if (elemDecl->getComplexTypeInfo()) - xsType = addOrFind(elemDecl->getComplexTypeInfo(), xsModel); - else if (elemDecl->getDatatypeValidator()) + // defer checking for complextypeinfo until later as it could + // eventually need this elemement + if (elemDecl->getDatatypeValidator()) xsType = addOrFind(elemDecl->getDatatypeValidator(), xsModel); unsigned int count = elemDecl->getIdentityConstraintCount(); @@ -491,6 +494,12 @@ XSObjectFactory::addOrFind(SchemaElementDecl* const elemDecl, , fMemoryManager ); putObjectInMap(elemDecl, xsObj, xsModel); + + if (!xsType && elemDecl->getComplexTypeInfo()) + { + xsType = addOrFind(elemDecl->getComplexTypeInfo(), xsModel); + xsObj->setTypeDefinition(xsType); + } } return xsObj; -- GitLab