saturate your adds

Bug: oss-fuzz:6149
Change-Id: Ia9a7b1e4a0d3dbbdcfb4469a8c50ffa512574fd1
Reviewed-on: https://skia-review.googlesource.com/125461
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Mike Reed 2018-05-03 11:26:36 -04:00 committed by Skia Commit-Bot
parent 8ba34f82dd
commit 9afad68453

View File

@ -14,6 +14,7 @@
#include "SkMatrixImageFilter.h"
#include "SkReadBuffer.h"
#include "SkRect.h"
#include "SkSafe32.h"
#include "SkSpecialImage.h"
#include "SkSpecialSurface.h"
#include "SkValidationUtils.h"
@ -72,14 +73,14 @@ void SkImageFilter::CropRect::applyTo(const SkIRect& imageBounds,
cropped->fLeft = devICropR.fLeft;
}
} else {
devICropR.fRight = cropped->fLeft + devICropR.width();
devICropR.fRight = Sk32_sat_add(cropped->fLeft, devICropR.width());
}
if (fFlags & kHasTop_CropEdge) {
if (embiggen || devICropR.fTop > cropped->fTop) {
cropped->fTop = devICropR.fTop;
}
} else {
devICropR.fBottom = cropped->fTop + devICropR.height();
devICropR.fBottom = Sk32_sat_add(cropped->fTop, devICropR.height());
}
if (fFlags & kHasWidth_CropEdge) {
if (embiggen || devICropR.fRight < cropped->fRight) {