summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-02-15 14:46:32 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-02-15 14:47:19 +0000
commitf18e476308845c6b4acde4e8009c3ca21bbe0621 (patch)
treede437334bb19d746994626af2699cc739dae12dc /filter
parent445a3d0a8d891b872b7fb0611e98de508d4fa1ae (diff)
assume max compression of 255 for ras
Change-Id: I51dfa45b266b6b9361f48aac58f0a4bca8446bdd
Diffstat (limited to 'filter')
-rw-r--r--filter/source/graphicfilter/iras/iras.cxx15
1 files changed, 10 insertions, 5 deletions
diff --git a/filter/source/graphicfilter/iras/iras.cxx b/filter/source/graphicfilter/iras/iras.cxx
index 30d618ef6032..9cc98ad45bf1 100644
--- a/filter/source/graphicfilter/iras/iras.cxx
+++ b/filter/source/graphicfilter/iras/iras.cxx
@@ -168,12 +168,17 @@ bool RASReader::ReadRAS(Graphic & rGraphic)
if (!bOk)
return false;
- if (mnType != RAS_TYPE_BYTE_ENCODED) //simple raw format
+ //The RLE packets are typically three bytes in size:
+ //The first byte is a Flag Value indicating the type of RLE packet.
+ //The second byte is the Run Count.
+ //The third byte is the Run Value.
+ //
+ //for the sake of simplicity we'll assume that RAS_TYPE_BYTE_ENCODED can
+ //describe data 255 times larger than the data stored
+ size_t nMaxCompression = mnType != RAS_TYPE_BYTE_ENCODED ? 1 : 255;
+ if (m_rRAS.remainingSize() * nMaxCompression < static_cast<sal_uInt64>(mnHeight) * mnWidth * mnDepth / 8)
{
- if (m_rRAS.remainingSize() < static_cast<sal_uInt64>(mnHeight) * mnWidth * mnDepth / 8)
- {
- return false;
- }
+ return false;
}
Bitmap aBmp(Size(mnWidth, mnHeight), mnDstBitsPerPix);