You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Mike Giancola <mi...@gmail.com> on 2012/07/10 16:19:50 UTC
Prevent exception from being thrown
Hi,
If a user calls XMLScanner::setExternalNoNamespaceSchemaLocation or
setExternalNoNamespaceSchemaLocation with an emptry string (not null) we
throw a c++ exception.
The fix: inside IGXMLScanner.cpp ::scanStartTagNS we check if the char*
pointers are null, but not empty. I suggest we add a gate for empty
strings. For example:
current gate:
if (isRoot && fDoSchema && (fExternalSchemaLocation ||
fExternalNoNamespaceSchemaLocation)) {
// proposed change:
if (XMLString::stringLen(fExternalSchemaLocation) > 0)
parseSchemaLocation(fExternalSchemaLocation, true);
if (XMLString::stringLen(fExternalNoNamespaceLocation) > 0)
resolveSchemaGrammer(fExternalNoNamespaceSchemaLocation,
XMLUni::fgZeroLenString, true);
}
*** reasons **
when we call scanDocument, it calls scanContent, scanContent calls
scanStartTagNS - if fExternalNoNamespaceSchemlaLocation = "" ....
we call resolveSchemaGrammer, which calls, parse, which calls scanDocument,
which calls scanReset, which calls createReader which calls
LocalFileInputSource::makeStream - which calls BinFileInputStream with an
empty file name.
The call to MakeStream fails since we can't open filename "". This causes
an error code to be returned to IGXMLScannner::scanReset - (newReader is
null). This causes us to attempt to throw an XML exception of
XMLExcepts::Scan_CouldNotOpenSource_Warning.
When we attempt to call this ThrowXMLwithMemMgr1 - we run into trouble. I
haven't traced this yet, but in debugger i get "First chance exception at
... in ... Microsoft C++ exception: xercesc_3_1::RuntimeException at memory
location .."
There appears to be something naughty going on with a free - but as i say,
i haven't traced this yet.
To repro this, just set the fExternalNoNamespaceLocation = "".
Thanks,
Mike