You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2010/04/13 10:53:39 UTC
svn commit: r933523 -
/xerces/c/branches/xerces-3.1/src/xercesc/util/TransService.cpp
Author: amassari
Date: Tue Apr 13 08:53:39 2010
New Revision: 933523
URL: http://svn.apache.org/viewvc?rev=933523&view=rev
Log:
If the transcoder doesn't process any input, throw an exception [XERCESC-1916]
Modified:
xerces/c/branches/xerces-3.1/src/xercesc/util/TransService.cpp
Modified: xerces/c/branches/xerces-3.1/src/xercesc/util/TransService.cpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-3.1/src/xercesc/util/TransService.cpp?rev=933523&r1=933522&r2=933523&view=diff
==============================================================================
--- xerces/c/branches/xerces-3.1/src/xercesc/util/TransService.cpp (original)
+++ xerces/c/branches/xerces-3.1/src/xercesc/util/TransService.cpp Tue Apr 13 08:53:39 2010
@@ -39,6 +39,7 @@
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/TransENameMap.hpp>
#include <xercesc/util/XMLInitializer.hpp>
+#include <xercesc/util/TranscodingException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -620,6 +621,9 @@ void TranscodeToStr::transcode(const XML
fBytesWritten += trans->transcodeTo(in + charsDone, len - charsDone,
fString + fBytesWritten, allocSize - fBytesWritten,
charsRead, XMLTranscoder::UnRep_Throw);
+ if(charsRead == 0)
+ ThrowXMLwithMemMgr(TranscodingException, XMLExcepts::Trans_BadSrcSeq, fMemoryManager);
+
charsDone += charsRead;
if(charsDone == len) break;
@@ -632,7 +636,7 @@ void TranscodeToStr::transcode(const XML
}
// null terminate
- if(fBytesWritten + 4 > allocSize) {
+ if((fBytesWritten + 4) > allocSize) {
allocSize = fBytesWritten + 4;
XMLByte *newBuf = (XMLByte*)fMemoryManager->allocate(allocSize);
memcpy(newBuf, fString, fBytesWritten);
@@ -699,6 +703,9 @@ void TranscodeFromStr::transcode(const X
fCharsWritten += trans->transcodeFrom(in + bytesDone, length - bytesDone,
fString + fCharsWritten, allocSize - fCharsWritten,
bytesRead, charSizes.get());
+ if(bytesRead == 0)
+ ThrowXMLwithMemMgr(TranscodingException, XMLExcepts::Trans_BadSrcSeq, fMemoryManager);
+
bytesDone += bytesRead;
if(bytesDone == length) break;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org