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

Caolán McNamara caolanm at redhat.com
Mon Mar 13 09:32:24 UTC 2017


 filter/source/graphicfilter/ios2met/ios2met.cxx |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

New commits:
commit 99b40c2eac242b9bc8674f09df8aaa53d6c836d0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 13 09:31:03 2017 +0000

    ofz#837 divide by zero in met
    
    Change-Id: I7acdea720ba29eb9b9fb3ef8e8cbc76a673d17c2

diff --git a/filter/source/graphicfilter/ios2met/ios2met.cxx b/filter/source/graphicfilter/ios2met/ios2met.cxx
index 0faf7c3..2bc052f 100644
--- a/filter/source/graphicfilter/ios2met/ios2met.cxx
+++ b/filter/source/graphicfilter/ios2met/ios2met.cxx
@@ -2301,9 +2301,10 @@ void OS2METReader::ReadImageData(sal_uInt16 nDataID, sal_uInt16 nDataLen)
             // do have a different RGB ordering when using 24-bit
             std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[nDataLen]);
             pOS2MET->ReadBytes(pBuf.get(), nDataLen);
-            if (p->nBitsPerPixel==24) {
-                sal_uLong nBytesPerLine = (p->nWidth * 3 + 3) & 0xfffffffc;
-                sal_uLong nAlign = p->nMapPos - (p->nMapPos % nBytesPerLine);
+            sal_uLong nBytesPerLineToSwap = (p->nBitsPerPixel == 24) ?
+                ((p->nWidth * 3 + 3) & 0xfffffffc) : 0;
+            if (nBytesPerLineToSwap) {
+                sal_uLong nAlign = p->nMapPos - (p->nMapPos % nBytesPerLineToSwap);
                 sal_uLong i=0;
                 while (nAlign+i+2<p->nMapPos+nDataLen) {
                     if (nAlign+i>=p->nMapPos) {
@@ -2311,8 +2312,8 @@ void OS2METReader::ReadImageData(sal_uInt16 nDataID, sal_uInt16 nDataLen)
                         std::swap(pBuf[j], pBuf[j+2]);
                     }
                     i+=3;
-                    if (i+2>=nBytesPerLine) {
-                        nAlign+=nBytesPerLine;
+                    if (i + 2 >= nBytesPerLineToSwap) {
+                        nAlign += nBytesPerLineToSwap;
                         i=0;
                     }
                 }


More information about the Libreoffice-commits mailing list