diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-03-13 09:31:03 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-03-13 09:31:03 +0000 |
commit | 99b40c2eac242b9bc8674f09df8aaa53d6c836d0 (patch) | |
tree | af7409925e64a10f5f97d464efef4e3997e4d3e2 /filter | |
parent | d4b89fdb51c0936c50457a2f1e8f6b38d5dd7eb2 (diff) |
ofz#837 divide by zero in met
Change-Id: I7acdea720ba29eb9b9fb3ef8e8cbc76a673d17c2
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/graphicfilter/ios2met/ios2met.cxx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/filter/source/graphicfilter/ios2met/ios2met.cxx b/filter/source/graphicfilter/ios2met/ios2met.cxx index 0faf7c313af0..2bc052f57bd0 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; } } |