From e957f932c8b8ece0536086b50a07afdf3a967a0c Mon Sep 17 00:00:00 2001
From: Alberto Massari <amassari@apache.org>
Date: Wed, 9 Mar 2005 16:07:11 +0000
Subject: [PATCH] Protected getSrcOffset to avoid crashing when parsing has
 finished; updated documentation

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@176340 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/internal/ReaderMgr.hpp        | 5 ++++-
 src/xercesc/parsers/DOMBuilderImpl.hpp    | 1 +
 src/xercesc/parsers/SAX2XMLFilterImpl.hpp | 4 ++++
 src/xercesc/parsers/SAX2XMLReaderImpl.hpp | 4 ++++
 src/xercesc/parsers/SAXParser.hpp         | 4 ++++
 src/xercesc/parsers/XercesDOMParser.hpp   | 1 +
 src/xercesc/sax2/SAX2XMLReader.hpp        | 4 ++++
 7 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/xercesc/internal/ReaderMgr.hpp b/src/xercesc/internal/ReaderMgr.hpp
index 0e0097e5f..9b66c6baa 100644
--- a/src/xercesc/internal/ReaderMgr.hpp
+++ b/src/xercesc/internal/ReaderMgr.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.16  2005/03/09 16:07:11  amassari
+ * Protected getSrcOffset to avoid crashing when parsing has finished; updated documentation
+ *
  * Revision 1.15  2005/02/08 09:21:11  amassari
  * Removed warnings
  *
@@ -412,7 +415,7 @@ inline bool ReaderMgr::getThrowEOE() const
 
 inline unsigned int ReaderMgr::getSrcOffset() const
 {
-    return fCurReader->getSrcOffset();
+    return fCurReader? fCurReader->getSrcOffset() : 0;
 }
 
 inline bool ReaderMgr::lookingAtChar(const XMLCh chToCheck)
diff --git a/src/xercesc/parsers/DOMBuilderImpl.hpp b/src/xercesc/parsers/DOMBuilderImpl.hpp
index 092525180..bb80c9d64 100644
--- a/src/xercesc/parsers/DOMBuilderImpl.hpp
+++ b/src/xercesc/parsers/DOMBuilderImpl.hpp
@@ -652,6 +652,7 @@ public :
 
     /**
       * Returns the current src offset within the input source.
+      * To be used only while parsing is in progress.
       *
       * @return offset within the input source
       */
diff --git a/src/xercesc/parsers/SAX2XMLFilterImpl.hpp b/src/xercesc/parsers/SAX2XMLFilterImpl.hpp
index e13b91ce4..128057554 100644
--- a/src/xercesc/parsers/SAX2XMLFilterImpl.hpp
+++ b/src/xercesc/parsers/SAX2XMLFilterImpl.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.3  2005/03/09 16:07:09  amassari
+ * Protected getSrcOffset to avoid crashing when parsing has finished; updated documentation
+ *
  * Revision 1.2  2005/01/06 21:39:44  amassari
  * Removed warnings
  *
@@ -473,6 +476,7 @@ public :
 
     /**
       * Returns the current src offset within the input source.
+      * To be used only while parsing is in progress.
       *
       * @return offset within the input source
       */
diff --git a/src/xercesc/parsers/SAX2XMLReaderImpl.hpp b/src/xercesc/parsers/SAX2XMLReaderImpl.hpp
index 71985b6ac..36a2fbaa0 100644
--- a/src/xercesc/parsers/SAX2XMLReaderImpl.hpp
+++ b/src/xercesc/parsers/SAX2XMLReaderImpl.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.31  2005/03/09 16:07:10  amassari
+ * Protected getSrcOffset to avoid crashing when parsing has finished; updated documentation
+ *
  * Revision 1.30  2005/02/25 11:31:07  amassari
  * Performance improvements by David Bertoni (jira# 1343)
  *
@@ -729,6 +732,7 @@ public :
 
     /**
       * Returns the current src offset within the input source.
+      * To be used only while parsing is in progress.
       *
       * @return offset within the input source
       */
diff --git a/src/xercesc/parsers/SAXParser.hpp b/src/xercesc/parsers/SAXParser.hpp
index c194dc776..5073fef45 100644
--- a/src/xercesc/parsers/SAXParser.hpp
+++ b/src/xercesc/parsers/SAXParser.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.38  2005/03/09 16:07:10  amassari
+ * Protected getSrcOffset to avoid crashing when parsing has finished; updated documentation
+ *
  * Revision 1.37  2004/12/07 19:45:43  knoaman
  * An option to ignore a cached DTD grammar when a document contains an
  * internal and external subset.
@@ -657,6 +660,7 @@ public :
 
     /**
      * Returns the current src offset within the input source.
+     * To be used only while parsing is in progress.
      *
      * @return offset within the input source
      */
diff --git a/src/xercesc/parsers/XercesDOMParser.hpp b/src/xercesc/parsers/XercesDOMParser.hpp
index 88bbe2310..a1ff5a639 100644
--- a/src/xercesc/parsers/XercesDOMParser.hpp
+++ b/src/xercesc/parsers/XercesDOMParser.hpp
@@ -195,6 +195,7 @@ public :
 
     /**
      * Returns the current src offset within the input source.
+     * To be used only while parsing is in progress.
      *
      * @return offset within the input source
      */
diff --git a/src/xercesc/sax2/SAX2XMLReader.hpp b/src/xercesc/sax2/SAX2XMLReader.hpp
index cc53c17c2..0f532e2a5 100644
--- a/src/xercesc/sax2/SAX2XMLReader.hpp
+++ b/src/xercesc/sax2/SAX2XMLReader.hpp
@@ -16,6 +16,9 @@
 
 /*
  * $Log$
+ * Revision 1.15  2005/03/09 16:07:11  amassari
+ * Protected getSrcOffset to avoid crashing when parsing has finished; updated documentation
+ *
  * Revision 1.14  2005/01/06 21:39:44  amassari
  * Removed warnings
  *
@@ -601,6 +604,7 @@ public:
 
     /**
       * Returns the current src offset within the input source.
+      * To be used only while parsing is in progress.
       *
       * @return offset within the input source
       */
-- 
GitLab