From d03d3e7fc04c83745722130573d01411fd88ba99 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Thu, 4 Mar 2021 23:24:02 +0000 Subject: [PATCH] ImageOperations::Resize to handle OOM. ImageOperations::Resize must allocate a backing buffer for the resized image. It is already attempting to handle OOM by returning an empty image on failure. However, it is calling allocPixels which will crash if the allocation is not satisfiable instead of tryAllocPixels which can return a status to state if the allocation succeeded. Bug: chromium:1182512 Change-Id: I44843f681655029f45c235c325acaec3588b64a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2737215 Reviewed-by: Mike Klein Commit-Queue: Ben Wagner Cr-Commit-Position: refs/heads/master@{#860005} --- skia/ext/image_operations.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/skia/ext/image_operations.cc b/skia/ext/image_operations.cc index f4b8d99bb1e67b..d2ce4afa3a733f 100644 --- a/skia/ext/image_operations.cc +++ b/skia/ext/image_operations.cc @@ -375,8 +375,7 @@ SkBitmap ImageOperations::Resize(const SkPixmap& source, SkBitmap result; result.setInfo( source.info().makeWH(dest_subset.width(), dest_subset.height())); - result.allocPixels(allocator); - if (!result.readyToDraw()) + if (!result.tryAllocPixels(allocator) || !result.readyToDraw()) return SkBitmap(); BGRAConvolve2D(source_subset, static_cast(source.rowBytes()),