From a2cf019d399e5e270bda810d511b28a6a7324b22 Mon Sep 17 00:00:00 2001 From: Neil Graham <neilg@apache.org> Date: Wed, 3 Dec 2003 20:00:27 +0000 Subject: [PATCH] PSVI fix: cannot allow validator to reset its element content buffer before exposing it to the application git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@175523 13f79535-47bb-0310-9956-ffa450edef68 --- src/xercesc/internal/IGXMLScanner.cpp | 3 +++ src/xercesc/internal/SGXMLScanner.cpp | 3 +++ src/xercesc/validators/schema/SchemaValidator.cpp | 6 +++++- src/xercesc/validators/schema/SchemaValidator.hpp | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/xercesc/internal/IGXMLScanner.cpp b/src/xercesc/internal/IGXMLScanner.cpp index 4ffa16380..072a00026 100644 --- a/src/xercesc/internal/IGXMLScanner.cpp +++ b/src/xercesc/internal/IGXMLScanner.cpp @@ -1194,6 +1194,9 @@ void IGXMLScanner::scanEndTag(bool& gotData) endElementPSVI( (SchemaElementDecl*)topElem->fThisElement, psviMemberType); } + // now we can reset the datatype buffer, since the + // application has had a chance to copy the characters somewhere else + ((SchemaValidator *)fValidator)->clearDatatypeBuffer(); } // If we have a doc handler, tell it about the end tag diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp index 1aac88111..e1e941ae5 100644 --- a/src/xercesc/internal/SGXMLScanner.cpp +++ b/src/xercesc/internal/SGXMLScanner.cpp @@ -1102,6 +1102,9 @@ void SGXMLScanner::scanEndTag(bool& gotData) (SchemaElementDecl*)topElem->fThisElement, psviMemberType ); } + // now we can reset the datatype buffer, since the + // application has had a chance to copy the characters somewhere else + ((SchemaValidator *)fValidator)->clearDatatypeBuffer(); // If we have a doc handler, tell it about the end tag if (fDocHandler) diff --git a/src/xercesc/validators/schema/SchemaValidator.cpp b/src/xercesc/validators/schema/SchemaValidator.cpp index 3f403920c..d9dae74f1 100644 --- a/src/xercesc/validators/schema/SchemaValidator.cpp +++ b/src/xercesc/validators/schema/SchemaValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.47 2003/12/03 20:00:27 neilg + * PSVI fix: cannot allow validator to reset its element content buffer before exposing it to the application + * * Revision 1.46 2003/11/27 22:52:37 knoaman * PSVIElement implementation * @@ -541,7 +544,8 @@ int SchemaValidator::checkContent (XMLElementDecl* const elemDecl ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMType); } - fDatatypeBuffer.reset(); + // must rely on scanner to clear fDatatypeBuffer + // since it may need to query its contents after this method completes fNil = false; fTrailing=false; diff --git a/src/xercesc/validators/schema/SchemaValidator.hpp b/src/xercesc/validators/schema/SchemaValidator.hpp index ad85d7589..9ec598146 100644 --- a/src/xercesc/validators/schema/SchemaValidator.hpp +++ b/src/xercesc/validators/schema/SchemaValidator.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.24 2003/12/03 20:00:27 neilg + * PSVI fix: cannot allow validator to reset its element content buffer before exposing it to the application + * * Revision 1.23 2003/11/28 21:18:32 knoaman * Make use of canonical representation in PSVIElement * @@ -266,6 +269,7 @@ public: void setErrorReporter(XMLErrorReporter* const errorReporter); void setExitOnFirstFatal(const bool newValue); void setDatatypeBuffer(const XMLCh* const value); + void clearDatatypeBuffer(); // ----------------------------------------------------------------------- // Getter methods @@ -461,6 +465,11 @@ inline void SchemaValidator::setDatatypeBuffer(const XMLCh* const value) fDatatypeBuffer.append(value); } +inline void SchemaValidator::clearDatatypeBuffer() +{ + fDatatypeBuffer.reset(); +} + // --------------------------------------------------------------------------- // SchemaValidator: Getter methods // --------------------------------------------------------------------------- -- GitLab