summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-02-02 10:00:53 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-02-02 10:57:19 +0000
commit71b87e381bc8cbab588cf4194c2b290b0531d5b4 (patch)
treedb352272c1b7f20e069bbe3bf0d33ab269dc48e2 /tools
parentcbe24d8988b41338d0c712e86ec18f7e3f1f86d8 (diff)
coverity#1242531 Untrusted value as argument
Change-Id: I86e872251f7b8b0818a91c4a133f363e76be5f34
Diffstat (limited to 'tools')
-rw-r--r--tools/source/generic/poly.cxx14
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index f104a33263c8..e4153b9af6f9 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1540,6 +1540,14 @@ SvStream& ReadPolygon( SvStream& rIStream, Polygon& rPoly )
// read all points and create array
rIStream.ReadUInt16( nPoints );
+
+ const size_t nMaxRecordsPossible = rIStream.remainingSize() / (2 * sizeof(sal_Int32));
+ if (nPoints > nMaxRecordsPossible)
+ {
+ SAL_WARN("tools", "Polygon claims " << nPoints << " records, but only " << nMaxRecordsPossible << " possible");
+ nPoints = nMaxRecordsPossible;
+ }
+
if ( rPoly.mpImplPolygon->mnRefCount != 1 )
{
if ( rPoly.mpImplPolygon->mnRefCount )
@@ -1551,12 +1559,6 @@ SvStream& ReadPolygon( SvStream& rIStream, Polygon& rPoly )
{
// Determine whether we need to write through operators
- const size_t nMaxRecordsPossible = rIStream.remainingSize() / (2 * sizeof(sal_Int32));
- if (nPoints > nMaxRecordsPossible)
- {
- SAL_WARN("tools", "Polygon claims " << nPoints << " records, but only " << nMaxRecordsPossible << " possible");
- nPoints = nMaxRecordsPossible;
- }
#if (SAL_TYPES_SIZEOFLONG) == 4
#ifdef OSL_BIGENDIAN
if ( rIStream.GetEndian() == SvStreamEndian::BIG )