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 2004/07/23 18:05:50 UTC
cvs commit: xml-xerces/c/src/xercesc/util/Transcoders/IconvFBSD IconvFBSDTransService.cpp
amassari 2004/07/23 09:05:50
Modified: c/src/xercesc/util/Transcoders/IconvFBSD
IconvFBSDTransService.cpp
Log:
transcode was badly terminating the converted string (jira#1179)
Revision Changes Path
1.16 +9 -7 xml-xerces/c/src/xercesc/util/Transcoders/IconvFBSD/IconvFBSDTransService.cpp
Index: IconvFBSDTransService.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Transcoders/IconvFBSD/IconvFBSDTransService.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- IconvFBSDTransService.cpp 24 Dec 2003 15:24:15 -0000 1.15
+++ IconvFBSDTransService.cpp 23 Jul 2004 16:05:50 -0000 1.16
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.16 2004/07/23 16:05:50 amassari
+ * transcode was badly terminating the converted string (jira#1179)
+ *
* Revision 1.15 2003/12/24 15:24:15 cargilld
* More updates to memory management so that the static memory manager.
*
@@ -1274,8 +1277,6 @@
if (wLent > maxBytes)
wLent = maxBytes;
- size_t mblen;
-
#ifndef XML_USE_LIBICONV
wchar_t tmpWideCharArr[gTempBuffArraySize];
@@ -1295,7 +1296,7 @@
wideCharBuf[wLent] = 0x00;
// Ok, go ahead and try the transcoding. If it fails, then ...
- mblen = fbsd_wcstombs(toFill, wideCharBuf, maxBytes);
+ size_t mblen = fbsd_wcstombs(toFill, wideCharBuf, maxBytes);
if (mblen == -1) {
if (allocatedArray)
manager->deallocate(allocatedArray);//delete [] allocatedArray;
@@ -1304,6 +1305,8 @@
if (allocatedArray)
manager->deallocate(allocatedArray);//delete [] allocatedArray;
+ // Cap it off just in case
+ toFill[mblen] = 0;
#else /* XML_USE_LIBICONV */
// Fill the "unicode" string
@@ -1331,8 +1334,8 @@
// Ok, go ahead and try the transcoding. If it fails, then ...
char *ptr = toFill;
- mblen = iconvTo(wideCharBuf, &len, &ptr, maxBytes);
- if (mblen == (size_t)-1) {
+ size_t rc = iconvTo(wideCharBuf, &len, &ptr, maxBytes);
+ if (rc == (size_t)-1) {
if (wBufPtr)
manager->deallocate(wBufPtr);//delete [] wBufPtr;
return false;
@@ -1340,10 +1343,9 @@
if (wBufPtr)
manager->deallocate(wBufPtr);//delete [] wBufPtr;
+ *ptr = 0;
#endif /* !XML_USE_LIBICONV */
- // Cap it off just in case
- toFill[mblen] = 0;
return true;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org