From 337c2dd42086c56696c57830bb3953554a973511 Mon Sep 17 00:00:00 2001 From: reed Date: Thu, 2 Oct 2014 12:58:48 -0700 Subject: [PATCH] check for newSurface failure BUG=skia: Review URL: https://codereview.chromium.org/622063003 --- bench/DeferredSurfaceCopyBench.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bench/DeferredSurfaceCopyBench.cpp b/bench/DeferredSurfaceCopyBench.cpp index cbf98ec8a1..e1c3e3b506 100644 --- a/bench/DeferredSurfaceCopyBench.cpp +++ b/bench/DeferredSurfaceCopyBench.cpp @@ -38,6 +38,13 @@ protected: const SkRect fullCanvasRect = SkRect::MakeWH( SkIntToScalar(kSurfaceWidth), SkIntToScalar(kSurfaceHeight)); SkAutoTUnref surface(canvas->newSurface(info)); + + // newSurface() can return NULL for several reasons, so we need to check + if (NULL == surface.get()) { + SkDebugf("DeferredSurfaceCopyBench newSurface failed, bench results are meaningless\n"); + return; // should we signal the caller that we hit an error? + } + SkAutoTUnref drawingCanvas(SkDeferredCanvas::Create(surface)); for (int iteration = 0; iteration < loops; iteration++) {