summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-01-20 13:21:36 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-01-20 13:32:33 +0000
commit6cf58a33676cebc9f2c1d26163793ba7dce46262 (patch)
tree028adf29426ef31cb2d4fb25c3e440673a811667 /vcl
parent40809ce46999e9cedb2fe5db8e9d53ebb6c182bf (diff)
accidentally ran make with VALGRIND set and walked away...
and found this bug triggered by CppunitTest_filter_eps_test when I got back Change-Id: I20943e5bd0fbf8aed923699dd5f1e88fada43e81
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/filter/graphicfilter.cxx28
1 files changed, 16 insertions, 12 deletions
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 0ca46985bd08..ebcb074358e2 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -255,9 +255,8 @@ bool isPCT(SvStream& rStream, sal_uLong nStreamPos, sal_uLong nStreamLen)
static bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension, bool bTest )
{
- sal_uInt16 i;
sal_uInt8 sFirstBytes[ 256 ];
- sal_uLong nFirstLong,nSecondLong;
+ sal_uLong nFirstLong(0), nSecondLong(0);
sal_uLong nStreamPos = rStream.Tell();
rStream.Seek( STREAM_SEEK_TO_END );
@@ -274,28 +273,33 @@ static bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension,
nStreamLen = rStream.Tell() - nStreamPos;
rStream.Seek( nStreamPos );
}
+
if (!nStreamLen)
{
return false; // this prevents at least a STL assertion
}
else if (nStreamLen >= 256)
- { // load first 256 bytes into a buffer
- rStream.Read( sFirstBytes, 256 );
+ {
+ // load first 256 bytes into a buffer
+ sal_uLong nRead = rStream.Read(sFirstBytes, 256);
+ if (nRead < 256)
+ nStreamLen = nRead;
}
else
{
- rStream.Read( sFirstBytes, nStreamLen );
-
- for( i = (sal_uInt16) nStreamLen; i < 256; i++ )
- sFirstBytes[ i ]=0;
+ nStreamLen = rStream.Read(sFirstBytes, nStreamLen);
}
- if( rStream.GetError() )
+
+ if (rStream.GetError())
return false;
+ for (sal_uLong i = nStreamLen; i < 256; ++i)
+ sFirstBytes[i] = 0;
+
// Accommodate the first 8 bytes in nFirstLong, nSecondLong
// Big-Endian:
- for( i = 0, nFirstLong = 0L, nSecondLong = 0L; i < 4; i++ )
+ for (int i = 0; i < 4; ++i)
{
nFirstLong=(nFirstLong<<8)|(sal_uLong)sFirstBytes[i];
nSecondLong=(nSecondLong<<8)|(sal_uLong)sFirstBytes[i+4];
@@ -324,7 +328,7 @@ static bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension,
sal_uInt8 nMagic;
bool bOK=true;
rStream.ReadUInt16( nFieldSize ).ReadUChar( nMagic );
- for (i=0; i<3; i++) {
+ for (int i=0; i<3; i++) {
if (nFieldSize<6) { bOK=false; break; }
if (nStreamLen < rStream.Tell() + nFieldSize ) { bOK=false; break; }
rStream.SeekRel(nFieldSize-3);
@@ -525,7 +529,7 @@ static bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension,
}
// ASCII DXF File Format
- i=0;
+ int i=0;
while (i<256 && sFirstBytes[i]<=32)
++i;