You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2001/12/07 21:13:30 UTC
cvs commit: xml-xalan/c/src/PlatformSupport XalanNumberFormat.cpp
dbertoni 01/12/07 12:13:30
Modified: c/src/PlatformSupport XalanNumberFormat.cpp
Log:
Make sure not to underun the buffer.
Revision Changes Path
1.11 +4 -3 xml-xalan/c/src/PlatformSupport/XalanNumberFormat.cpp
Index: XalanNumberFormat.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanNumberFormat.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XalanNumberFormat.cpp 2001/09/25 21:12:51 1.10
+++ XalanNumberFormat.cpp 2001/12/07 20:13:30 1.11
@@ -245,7 +245,8 @@
}
else
{
- const XalanDOMString::size_type bufsize = len + len/m_groupingSize + 1;
+ // Add two, so we leave one byte at the beginning as empty space
+ const XalanDOMString::size_type bufsize = len + len / m_groupingSize + 2;
XalanDOMChar* const buffer = new XalanDOMChar[bufsize];
@@ -255,14 +256,14 @@
*p-- = 0; // null terminate
- for (XalanDOMString::size_type i = 0, ix = len - 1; i < len; i++, ix--)
+ for (XalanDOMString::size_type i = 0, ix = len - 1; i < len && p > buffer; i++, ix--)
{
const XalanDOMChar c = charAt(value, ix);
if (i && !(i% m_groupingSize))
{
// Could be a multiple character separator??
- for (long j = long(m_groupingSeparator.length() - 1); j>=0; j--)
+ for (long j = long(m_groupingSeparator.length() - 1); j >= 0 && p > buffer; j--)
*p-- = charAt(m_groupingSeparator, j);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org