From f18e476308845c6b4acde4e8009c3ca21bbe0621 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 15 Feb 2017 14:46:32 +0000 Subject: assume max compression of 255 for ras Change-Id: I51dfa45b266b6b9361f48aac58f0a4bca8446bdd --- filter/source/graphicfilter/iras/iras.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'filter') 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(mnHeight) * mnWidth * mnDepth / 8) { - if (m_rRAS.remainingSize() < static_cast(mnHeight) * mnWidth * mnDepth / 8) - { - return false; - } + return false; } Bitmap aBmp(Size(mnWidth, mnHeight), mnDstBitsPerPix); -- cgit