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:52:12 UTC

svn commit: r933521 - /xerces/c/trunk/src/xercesc/util/TransService.cpp

Author: amassari
Date: Tue Apr 13 08:52:12 2010
New Revision: 933521

URL: http://svn.apache.org/viewvc?rev=933521&view=rev
Log:
If the transcoder doesn't process any input, throw an exception [XERCESC-1916]

Modified:
    xerces/c/trunk/src/xercesc/util/TransService.cpp

Modified: xerces/c/trunk/src/xercesc/util/TransService.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/TransService.cpp?rev=933521&r1=933520&r2=933521&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/TransService.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/TransService.cpp Tue Apr 13 08:52:12 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