tng 2002/11/14 14:15:31 Modified: c/src/xercesc/util XMLString.cpp Log: [Bug 14479] XMLString::subString failure when len(source)==0 Revision Changes Path 1.11 +16 -21 xml-xerces/c/src/xercesc/util/XMLString.cpp Index: XMLString.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLString.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- XMLString.cpp 4 Nov 2002 15:22:05 -0000 1.10 +++ XMLString.cpp 14 Nov 2002 22:15:31 -0000 1.11 @@ -592,25 +592,21 @@ void XMLString::subString(char* const targetStr, const char* const srcStr , const int startIndex, const int endIndex) { - //if (startIndex < 0 || endIndex < 0) - // ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Str_NegativeIndex); - - if (targetStr == 0) + if (targetStr == 0) ThrowXML(IllegalArgumentException, XMLExcepts::Str_ZeroSizedTargetBuf); const int srcLen = strlen(srcStr); - const int copySize = endIndex - startIndex; + const int copySize = endIndex - startIndex; // Make sure the start index is within the XMLString bounds - if (startIndex > srcLen-1 || endIndex > srcLen ) + if ( startIndex < 0 || startIndex > endIndex || endIndex > srcLen) ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd); - for (int i= startIndex; i < endIndex; i++) { - - targetStr[i-startIndex] = srcStr[i]; - } + for (int i= startIndex; i < endIndex; i++) { + targetStr[i-startIndex] = srcStr[i]; + } - targetStr[copySize] = 0; + targetStr[copySize] = 0; } /** @@ -1450,25 +1446,24 @@ void XMLString::subString(XMLCh* const targetStr, const XMLCh* const srcStr , const int startIndex, const int endIndex) { - //if (startIndex < 0 || endIndex < 0) + //if (startIndex < 0 || endIndex < 0) // ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Str_NegativeIndex); - if (targetStr == 0) + if (targetStr == 0) ThrowXML(IllegalArgumentException, XMLExcepts::Str_ZeroSizedTargetBuf); const int srcLen = stringLen(srcStr); - const int copySize = endIndex - startIndex; + const int copySize = endIndex - startIndex; // Make sure the start index is within the XMLString bounds - if (startIndex > srcLen-1 || endIndex > srcLen ) + if ( startIndex < 0 || startIndex > endIndex || endIndex > srcLen) ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd); - for (int i= startIndex; i < endIndex; i++) { - - targetStr[i-startIndex] = srcStr[i]; - } + for (int i= startIndex; i < endIndex; i++) { + targetStr[i-startIndex] = srcStr[i]; + } - targetStr[copySize] = 0; + targetStr[copySize] = 0; } RefVectorOf<XMLCh>* XMLString::tokenizeString(const XMLCh* const tokenizeSrc)
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]