From 8c240bfaf670fc70104d43ea60d065257bee64f6 Mon Sep 17 00:00:00 2001
From: Andy Heninger <andyh@apache.org>
Date: Fri, 8 Sep 2000 00:57:37 +0000
Subject: [PATCH] Fix to XMLReader::skippedString(), submitted by Bob Kline
 bkline@rksystems.com

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@172381 13f79535-47bb-0310-9956-ffa450edef68
---
 src/internal/XMLReader.cpp | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/internal/XMLReader.cpp b/src/internal/XMLReader.cpp
index ad05ee384..e38df318f 100644
--- a/src/internal/XMLReader.cpp
+++ b/src/internal/XMLReader.cpp
@@ -1057,14 +1057,18 @@ bool XMLReader::skippedString(const XMLCh* const toSkip)
     //  a string to skip will never have a new line in it, so we will never
     //  miss adjusting the current line.
     //
-    if (charsLeftInBuffer() < srcLen)
+    unsigned int charsLeft = charsLeftInBuffer();
+    while (charsLeft < srcLen)
     {
-        refreshCharBuffer();
+         refreshCharBuffer();
+         unsigned int t = charsLeftInBuffer();
+         if (t == charsLeft)   // if the refreshCharBuf() did not add anything new
+             return false;     //   give up and return.
+         charsLeft = t;
+	}
+
+
 
-        // Did we get enough chars to handle it yet?
-        if (charsLeftInBuffer() < srcLen)
-            return false;
-    }
 
     //
     //  Ok, now we now that the current reader has enough chars in its
@@ -1337,7 +1341,7 @@ void XMLReader::doInitDecode()
             //   Don't move to char buf - no one wants to see it.
             //   Note: this causes any encoding= declaration to override
             //         the BOM's attempt to say that the encoding is utf-8.
- 
+
             // Look at the raw buffer as short chars
             const char* asChars = (const char*)fRawByteBuf;
 
-- 
GitLab