You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Bob Kline <bk...@rksystems.com> on 2000/09/07 23:19:09 UTC

Bug in XMLReader

I found a problem in XMLReader.cpp which occasionally causes matches on
expected strings to fail.  The problem bit me when the parser reported
that it expected but didn't find a CDATA section.  When I stepped
through the code in the debugger, I found that the skippedString()
method was calling refreshCharBuffer() at most once.  Under certain
conditions, the refreshCharBuffer() only adds a very few characters to
the buffer.  In the case I stumbled across, there were 3 characters
available and refreshCharBuffer() added 2 more, so the attempt to match
the 7 characters of L"![CDATA" failed.  The attached patch fixes the
problem.

I ran into the problem with version 3.1.0 on Win2K and NT 4.0, using
MSVC++ 6.0 Enterprise Edition service pack 4, but I suspect that this is
a cross-platform bug.

[I originally reported this bug to xml4c@us.ibm.com, but was referred to
this list, since it doesn't look as if it's possible for non-IBM-ers to
join their mailing list.]

-- 
Bob Kline
mailto:bkline@rksystems.com
http://www.rksystems.com



Re: Bug in XMLReader

Posted by Bob Kline <bk...@rksystems.com>.
On Thu, 7 Sep 2000, Andy Heninger wrote:

> I tweaked your patch slightly and put it in.
> 

Thanks.

> I was a little worried that the original patch could go into
> a loop if the reader had some characters, but not enough,
> leaving it looping trying to add more.  refreshCharBuffer()
> appears to return true if there are any chars in the buffer,
> rather than if it added any (on a quick look; I'm not
> completely certain of this.).
> 

You may be right.  If so, it would probably be helpful to add a comment
to the refreshCharBuffer() method explaining that the boolean return
value doesn't mean what the name of the method implies that it means.

-- 
Bob Kline
mailto:bkline@rksystems.com
http://www.rksystems.com


Re: Bug in XMLReader

Posted by Andy Heninger <an...@jtcsv.com>.
I tweaked your patch slightly and put it in.

I was a little worried that the original patch could go into
a loop if the reader had some characters, but not enough,
leaving it looping trying to add more.  refreshCharBuffer()
appears to return true if there are any chars in the buffer,
rather than if it added any (on a quick look; I'm not
completely certain of this.).

Thanks for the catch and patch.

Andy Heninger
IBM XML Technology Group, Cupertino, CA
heninger@us.ibm.com


----- Original Message -----

From: "Bob Kline" <bk...@rksystems.com>
To: <xe...@xml.apache.org>
Sent: Thursday, September 07, 2000 2:19 PM
Subject: Bug in XMLReader


> I found a problem in XMLReader.cpp which occasionally causes matches on
> expected strings to fail.  The problem bit me when the parser reported
> that it expected but didn't find a CDATA section.  When I stepped
> through the code in the debugger, I found that the skippedString()
> method was calling refreshCharBuffer() at most once.  Under certain
> conditions, the refreshCharBuffer() only adds a very few characters to
> the buffer.  In the case I stumbled across, there were 3 characters
> available and refreshCharBuffer() added 2 more, so the attempt to match
> the 7 characters of L"![CDATA" failed.  The attached patch fixes the
> problem.
>
> I ran into the problem with version 3.1.0 on Win2K and NT 4.0, using
> MSVC++ 6.0 Enterprise Edition service pack 4, but I suspect that this is
> a cross-platform bug.
>
> [I originally reported this bug to xml4c@us.ibm.com, but was referred to
> this list, since it doesn't look as if it's possible for non-IBM-ers to
> join their mailing list.]
>
> --
> Bob Kline
> mailto:bkline@rksystems.com
> http://www.rksystems.com
>
>