[Libreoffice-commits] core.git: filter/source

Caolán McNamara caolanm at redhat.com
Wed Feb 15 14:47:39 UTC 2017


 filter/source/graphicfilter/iras/iras.cxx |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

New commits:
commit f18e476308845c6b4acde4e8009c3ca21bbe0621
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Feb 15 14:46:32 2017 +0000

    assume max compression of 255 for ras
    
    Change-Id: I51dfa45b266b6b9361f48aac58f0a4bca8446bdd

diff --git a/filter/source/graphicfilter/iras/iras.cxx b/filter/source/graphicfilter/iras/iras.cxx
index 30d618e..9cc98ad 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);


More information about the Libreoffice-commits mailing list