[Libreoffice-commits] core.git: 3 commits - svl/source
Eike Rathke
erack at redhat.com
Mon Aug 18 06:57:35 PDT 2014
svl/source/numbers/zformat.cxx | 66 +++++++++++++++++++----------------------
1 file changed, 32 insertions(+), 34 deletions(-)
New commits:
commit 349c93e0f5c9f231b2ff6854fcb795ca5881ca2d
Author: Eike Rathke <erack at redhat.com>
Date: Mon Aug 18 15:55:14 2014 +0200
more out-of-bounds string accesses
Change-Id: Id5df5775e4c5bfb1c484e60e6831f6bc77158d35
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 271a331..633b803 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2242,6 +2242,30 @@ short SvNumberformat::ImpCheckCondition(double& fNumber,
}
}
+static bool lcl_appendStarFillChar( OUStringBuffer& rBuf, const OUString& rStr )
+{
+ // Right during user input the star symbol is the very
+ // last character before the user enters another one.
+ if (rStr.getLength() > 1)
+ {
+ rBuf.append((sal_Unicode) 0x1B);
+ rBuf.append(rStr[1]);
+ return true;
+ }
+ return false;
+}
+
+static bool lcl_insertStarFillChar( OUStringBuffer& rBuf, sal_Int32 nPos, const OUString& rStr )
+{
+ if (rStr.getLength() > 1)
+ {
+ rBuf.insert( nPos, rStr[1]);
+ rBuf.insert( nPos, (sal_Unicode) 0x1B);
+ return true;
+ }
+ return false;
+}
+
bool SvNumberformat::GetOutputString(const OUString& sString,
OUString& OutString,
Color** ppColor)
@@ -2274,9 +2298,7 @@ bool SvNumberformat::GetOutputString(const OUString& sString,
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- sOutBuff.append((sal_Unicode) 0x1B);
- sOutBuff.append(rInfo.sStrArray[i][1]);
- bRes = true;
+ bRes = lcl_appendStarFillChar( sOutBuff, rInfo.sStrArray[i]);
}
break;
case NF_SYMBOLTYPE_BLANK:
@@ -2589,15 +2611,7 @@ bool SvNumberformat::GetOutputString(double fNumber,
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- const OUString& rStr =rInfo.sStrArray[i];
- // Right during user input the star symbol is the very
- // last character before the user enters another one.
- if (rStr.getLength() > 1)
- {
- sBuff.append((sal_Unicode) 0x1B);
- sBuff.append(rStr[1]);
- bRes = true;
- }
+ bRes = lcl_appendStarFillChar( sBuff, rInfo.sStrArray[i]);
}
break;
case NF_SYMBOLTYPE_BLANK:
@@ -3221,9 +3235,7 @@ bool SvNumberformat::ImpGetTimeOutput(double fNumber,
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- sBuff.append((sal_Unicode)0x1B);
- sBuff.append(rInfo.sStrArray[i][1]);
- bRes = true;
+ bRes = lcl_appendStarFillChar( sBuff, rInfo.sStrArray[i]);
}
break;
case NF_SYMBOLTYPE_BLANK:
@@ -3719,9 +3731,7 @@ bool SvNumberformat::ImpGetDateOutput(double fNumber,
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- sBuff.append((sal_Unicode) 0x1B);
- sBuff.append(rInfo.sStrArray[i][1]);
- bRes = true;
+ bRes = lcl_appendStarFillChar( sBuff, rInfo.sStrArray[i]);
}
break;
case NF_SYMBOLTYPE_BLANK:
@@ -4014,9 +4024,7 @@ bool SvNumberformat::ImpGetDateTimeOutput(double fNumber,
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- sBuff.append((sal_Unicode) 0x1B);
- sBuff.append(rInfo.sStrArray[i][1]);
- bRes = true;
+ bRes = lcl_appendStarFillChar( sBuff, rInfo.sStrArray[i]);
}
break;
case NF_SYMBOLTYPE_BLANK:
@@ -4347,9 +4355,7 @@ bool SvNumberformat::ImpGetNumberOutput(double fNumber,
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- sStr.insert(k, rInfo.sStrArray[j][1]);
- sStr.insert(k, (sal_Unicode) 0x1B);
- bRes = true;
+ bRes = lcl_insertStarFillChar( sStr, k, rInfo.sStrArray[j]);
}
break;
case NF_SYMBOLTYPE_BLANK:
@@ -4482,9 +4488,7 @@ bool SvNumberformat::ImpNumberFillWithThousands( OUStringBuffer& sBuff, // numb
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- sBuff.insert(k, rInfo.sStrArray[j][1]);
- sBuff.insert(k, (sal_Unicode) 0x1B);
- bRes = true;
+ bRes = lcl_insertStarFillChar( sBuff, k, rInfo.sStrArray[j]);
}
break;
case NF_SYMBOLTYPE_BLANK:
@@ -4658,9 +4662,7 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- sBuff.insert(k, rInfo.sStrArray[j][1]);
- sBuff.insert(k, sal_Unicode(0x1B));
- bRes = true;
+ bRes = lcl_insertStarFillChar( sBuff, k, rInfo.sStrArray[j]);
}
break;
case NF_SYMBOLTYPE_BLANK:
commit e442510a6109458d7dc1503b7e849dcc0b19cde8
Author: Eike Rathke <erack at redhat.com>
Date: Mon Aug 18 15:18:28 2014 +0200
do not even append the 0x1B in this case
Change-Id: I016869b9d2230dfe6af233b1c3ae9b6de4818ce7
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 212c6f1..271a331 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2589,12 +2589,12 @@ bool SvNumberformat::GetOutputString(double fNumber,
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- sBuff.append((sal_Unicode) 0x1B);
const OUString& rStr =rInfo.sStrArray[i];
// Right during user input the star symbol is the very
// last character before the user enters another one.
if (rStr.getLength() > 1)
{
+ sBuff.append((sal_Unicode) 0x1B);
sBuff.append(rStr[1]);
bRes = true;
}
commit 989f0e4c109a528c64e2377c16e59a1fa890677b
Author: Eike Rathke <erack at redhat.com>
Date: Mon Aug 18 15:13:02 2014 +0200
no need to set bRes=false here, it is already
Change-Id: I80f78e0d2078c4e56d4f2ef5842b180e6080e410
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 69e0059..212c6f1 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2598,10 +2598,6 @@ bool SvNumberformat::GetOutputString(double fNumber,
sBuff.append(rStr[1]);
bRes = true;
}
- else
- {
- bRes = false;
- }
}
break;
case NF_SYMBOLTYPE_BLANK:
More information about the Libreoffice-commits
mailing list