Kaydet (Commit) 958bcfc9 authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1266489 Untrusted loop bound

Change-Id: I5903dafb4bb29657a5b6e239cb918e656c381315
üst dada981a
...@@ -1165,19 +1165,29 @@ bool SwTableAutoFmtTbl::Load( SvStream& rStream ) ...@@ -1165,19 +1165,29 @@ bool SwTableAutoFmtTbl::Load( SvStream& rStream )
rStream.ReadUInt16( nAnz ); rStream.ReadUInt16( nAnz );
bRet = 0 == rStream.GetError(); bRet = 0 == rStream.GetError();
if (bRet)
for( sal_uInt16 i = 0; i < nAnz; ++i )
{ {
pNew = new SwTableAutoFmt( OUString() ); const size_t nMinRecordSize = sizeof(sal_uInt16);
bRet = pNew->Load( rStream, aVersions ); const size_t nMaxRecords = rStream.remainingSize() / nMinRecordSize;
if( bRet ) if (nAnz > nMaxRecords)
{ {
m_pImpl->m_AutoFormats.push_back(pNew); SAL_WARN("vcl.gdi", "Parsing error: " << nMaxRecords <<
" max possible entries, but " << nAnz << " claimed, truncating");
nAnz = nMaxRecords;
} }
else for (sal_uInt16 i = 0; i < nAnz; ++i)
{ {
delete pNew; pNew = new SwTableAutoFmt( OUString() );
break; bRet = pNew->Load( rStream, aVersions );
if( bRet )
{
m_pImpl->m_AutoFormats.push_back(pNew);
}
else
{
delete pNew;
break;
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment