fix ubsan warning
authorMike Klein <mtklein@chromium.org>
Mon, 22 May 2017 17:45:38 +0000 (13:45 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Mon, 22 May 2017 18:13:17 +0000 (18:13 +0000)
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-ASAN

Change-Id: Ic8c5d95fdb899cb5293b2bc456f61b1637ec3aed
Reviewed-on: https://skia-review.googlesource.com/17489
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>

src/jumper/SkJumper.cpp

index 0e184b9..8daf29e 100644 (file)
@@ -188,6 +188,9 @@ static void build_pipeline(const SkRasterPipeline::Stage* stages, int nstages,
 }
 
 void SkRasterPipeline::run(size_t x, size_t n) const {
+    if (fStages.empty()) {
+        return;
+    }
     gChooseEngineOnce([]{ gPlatform = choose_engine(); });
 
     SkAutoSTMalloc<64, void*> program(2*fStages.size() + 1);
@@ -204,6 +207,9 @@ void SkRasterPipeline::run(size_t x, size_t n) const {
 }
 
 std::function<void(size_t, size_t)> SkRasterPipeline::compile(SkArenaAlloc* alloc) const {
+    if (fStages.empty()) {
+        return [](size_t, size_t) {};
+    }
     gChooseEngineOnce([]{ gPlatform = choose_engine(); });
 
     void** platform = alloc->makeArray<void*>(2*fStages.size() + 1);