summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
Diffstat (limited to 'filter')
-rw-r--r--filter/source/graphicfilter/itiff/itiff.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx
index a2b8ddb06ae8..d2bb00e3720f 100644
--- a/filter/source/graphicfilter/itiff/itiff.cxx
+++ b/filter/source/graphicfilter/itiff/itiff.cxx
@@ -863,13 +863,16 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
sal_uInt8 nLAlpha = 0;
for (sal_Int32 nx = 0; nx < nImageWidth; nx++, pt += nSamplesPerPixel)
{
- nLRed = nLRed + pt[ 0 ];
- nLGreen = nLGreen + pt[ 1 ];
- nLBlue = nLBlue + pt[ 2 ];
+ // The following computations rely on sal_uInt8 wrap-around when adding the
+ // (unsigned) pt deltas; the "& 0xFF" is only conceptual, but helps prevent
+ // sanitizer warnings:
+ nLRed = (nLRed + pt[ 0 ]) & 0xFF;
+ nLGreen = (nLGreen + pt[ 1 ]) & 0xFF;
+ nLBlue = (nLBlue + pt[ 2 ]) & 0xFF;
SetPixel(nY, nx, Color(nLRed, nLGreen, nLBlue));
if (HasAlphaChannel())
{
- nLAlpha = nLAlpha + pt[ 3 ];
+ nLAlpha = (nLAlpha + pt[ 3 ]) & 0xFF;
SetPixelAlpha(nY, nx, ~nLAlpha);
}
}