Kaydet (Commit) 99b40c2e authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#837 divide by zero in met

Change-Id: I7acdea720ba29eb9b9fb3ef8e8cbc76a673d17c2
üst d4b89fdb
...@@ -2301,9 +2301,10 @@ void OS2METReader::ReadImageData(sal_uInt16 nDataID, sal_uInt16 nDataLen) ...@@ -2301,9 +2301,10 @@ void OS2METReader::ReadImageData(sal_uInt16 nDataID, sal_uInt16 nDataLen)
// do have a different RGB ordering when using 24-bit // do have a different RGB ordering when using 24-bit
std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[nDataLen]); std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[nDataLen]);
pOS2MET->ReadBytes(pBuf.get(), nDataLen); pOS2MET->ReadBytes(pBuf.get(), nDataLen);
if (p->nBitsPerPixel==24) { sal_uLong nBytesPerLineToSwap = (p->nBitsPerPixel == 24) ?
sal_uLong nBytesPerLine = (p->nWidth * 3 + 3) & 0xfffffffc; ((p->nWidth * 3 + 3) & 0xfffffffc) : 0;
sal_uLong nAlign = p->nMapPos - (p->nMapPos % nBytesPerLine); if (nBytesPerLineToSwap) {
sal_uLong nAlign = p->nMapPos - (p->nMapPos % nBytesPerLineToSwap);
sal_uLong i=0; sal_uLong i=0;
while (nAlign+i+2<p->nMapPos+nDataLen) { while (nAlign+i+2<p->nMapPos+nDataLen) {
if (nAlign+i>=p->nMapPos) { if (nAlign+i>=p->nMapPos) {
...@@ -2311,8 +2312,8 @@ void OS2METReader::ReadImageData(sal_uInt16 nDataID, sal_uInt16 nDataLen) ...@@ -2311,8 +2312,8 @@ void OS2METReader::ReadImageData(sal_uInt16 nDataID, sal_uInt16 nDataLen)
std::swap(pBuf[j], pBuf[j+2]); std::swap(pBuf[j], pBuf[j+2]);
} }
i+=3; i+=3;
if (i+2>=nBytesPerLine) { if (i + 2 >= nBytesPerLineToSwap) {
nAlign+=nBytesPerLine; nAlign += nBytesPerLineToSwap;
i=0; i=0;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment