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

Unified Diff: cc/output/software_renderer.cc

Issue 1952303002: cc: fix nullptr deref in software renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing test file Created 4 years, 7 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 | cc/test/data/white.png » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/software_renderer.cc
diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc
index 2d1d1a17964026b902d96d9a26e77c211b19c329..0fb8b928ed5cb748ee5c049d4ffbf48cbd872d72 100644
--- a/cc/output/software_renderer.cc
+++ b/cc/output/software_renderer.cc
@@ -498,16 +498,23 @@ void SoftwareRenderer::DrawRenderPassQuad(const DrawingFrame* frame,
if (!quad->filters.IsEmpty()) {
sk_sp<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
quad->filters, gfx::SizeF(content_texture->size()));
- SkIRect result_rect;
- // TODO(ajuma): Apply the filter in the same pass as the content where
- // possible (e.g. when there's no origin offset). See crbug.com/308201.
- filter_image = ApplyImageFilter(filter.get(), quad, *content, &result_rect);
- if (filter_image) {
- gfx::RectF rect = gfx::SkRectToRectF(SkRect::Make(result_rect));
- dest_rect = dest_visible_rect =
- gfx::RectFToSkRect(MathUtil::ScaleRectProportional(
- QuadVertexRect(), gfx::RectF(quad->rect), rect));
- content_rect = SkRect::MakeWH(result_rect.width(), result_rect.height());
+ if (filter) {
+ SkIRect result_rect;
+ // TODO(ajuma): Apply the filter in the same pass as the content where
+ // possible (e.g. when there's no origin offset). See crbug.com/308201.
+ filter_image =
+ ApplyImageFilter(filter.get(), quad, *content, &result_rect);
+ if (result_rect.isEmpty()) {
+ return;
+ }
+ if (filter_image) {
+ gfx::RectF rect = gfx::SkRectToRectF(SkRect::Make(result_rect));
+ dest_rect = dest_visible_rect =
+ gfx::RectFToSkRect(MathUtil::ScaleRectProportional(
+ QuadVertexRect(), gfx::RectF(quad->rect), rect));
+ content_rect =
+ SkRect::MakeWH(result_rect.width(), result_rect.height());
+ }
}
}
@@ -663,6 +670,10 @@ sk_sp<SkImage> SoftwareRenderer::ApplyImageFilter(
SkImageInfo::MakeN32Premul(dst_rect.width(), dst_rect.height());
sk_sp<SkSurface> surface = SkSurface::MakeRaster(dst_info);
+ if (!surface) {
+ return nullptr;
+ }
+
SkPaint paint;
paint.setImageFilter(filter->makeWithLocalMatrix(local_matrix));
surface->getCanvas()->translate(-dst_rect.x(), -dst_rect.y());
« no previous file with comments | « no previous file | cc/test/data/white.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698