diff options
author | 2024-08-21 13:21:26 +0000 | |
---|---|---|
committer | 2025-03-04 10:22:16 -0800 | |
commit | dc1f09b81a1b1aaa7d7e1bc9ea23cf95d58cb22f (patch) | |
tree | 876870497bb090b647e78cf4045e597e829a9b12 | |
parent | de26727317a9c90ca7936b77c37bcdccc5afaf1e (diff) |
Check return value of SkRect::intersect()
Skia is adding `[[nodiscard]]` to `Sk[I]Rect::intersect()` and this
appears to be the only callsite in Android that was not already
checking the return value.
Bug: b/40042853
Flag: EXEMPT bugfix
Change-Id: I45369f83041ea63fc00d29111c07b311e457ec20
-rw-r--r-- | libs/hwui/jni/Graphics.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libs/hwui/jni/Graphics.cpp b/libs/hwui/jni/Graphics.cpp index a210ddf54b2e..7d227f793817 100644 --- a/libs/hwui/jni/Graphics.cpp +++ b/libs/hwui/jni/Graphics.cpp @@ -722,10 +722,15 @@ void RecyclingClippingPixelAllocator::copyIfNecessary() { auto canvas = SkCanvas(recycledPixels->getSkBitmap()); SkRect destination = SkRect::Make(recycledPixels->info().bounds()); - destination.intersect(SkRect::Make(mSkiaBitmap->info().bounds())); - canvas.drawImageRect(mSkiaBitmap->asImage(), *mDesiredSubset, destination, - SkSamplingOptions(SkFilterMode::kLinear), nullptr, - SkCanvas::kFast_SrcRectConstraint); + if (destination.intersect(SkRect::Make(mSkiaBitmap->info().bounds()))) { + canvas.drawImageRect(mSkiaBitmap->asImage(), *mDesiredSubset, destination, + SkSamplingOptions(SkFilterMode::kLinear), nullptr, + SkCanvas::kFast_SrcRectConstraint); + } else { + // The canvas would have discarded the draw operation automatically, but + // this case should have been detected before getting to this point. + ALOGE("Copy destination does not intersect image bounds"); + } } else { void* dst = recycledPixels->pixels(); const size_t dstRowBytes = mRecycledBitmap->rowBytes(); |