Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: src/core/SkImageFilter.cpp

Issue 1800263002: Fix pointer aliasing bug in SkImageFilter::computeFastBounds. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: code review comments on unit test Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/ImageFilterTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageFilter.cpp
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 374a561030254561941ecf21e67d4a65cdfffe80..85f4e468dd699a8a75f62819f99960439dc8adfa 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -313,21 +313,24 @@ void SkImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
*dst = src;
return;
}
+ // We can't work directly on dst, since src and dst may alias.
+ SkRect combinedBounds;
if (this->getInput(0)) {
- this->getInput(0)->computeFastBounds(src, dst);
+ this->getInput(0)->computeFastBounds(src, &combinedBounds);
} else {
- *dst = src;
+ combinedBounds = src;
}
for (int i = 1; i < fInputCount; i++) {
SkImageFilter* input = this->getInput(i);
if (input) {
SkRect bounds;
input->computeFastBounds(src, &bounds);
- dst->join(bounds);
+ combinedBounds.join(bounds);
} else {
- dst->join(src);
+ combinedBounds.join(src);
}
}
+ *dst = combinedBounds;
}
bool SkImageFilter::canComputeFastBounds() const {
« no previous file with comments | « no previous file | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698