Skip to content

Commit

Permalink
ImageOperations::Resize to handle OOM.
Browse files Browse the repository at this point in the history
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 <mtklein@google.com>
Commit-Queue: Ben Wagner <bungeman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#860005}
  • Loading branch information
bungeman authored and Chromium LUCI CQ committed Mar 4, 2021
1 parent 6bc7619 commit d03d3e7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions skia/ext/image_operations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(source.rowBytes()),
Expand Down

0 comments on commit d03d3e7

Please sign in to comment.