Check for nullptrs when fuzzing region_deserialize
Bug: oss-fuzz:5629
Change-Id: I1129a6a9a68c69e07ab63e2e2be1c00cf0581962
Reviewed-on: https://skia-review.googlesource.com/102482
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
diff --git a/fuzz/oss_fuzz/FuzzRegionDeserialize.cpp b/fuzz/oss_fuzz/FuzzRegionDeserialize.cpp
index c5b37cb..80ee4f9 100644
--- a/fuzz/oss_fuzz/FuzzRegionDeserialize.cpp
+++ b/fuzz/oss_fuzz/FuzzRegionDeserialize.cpp
@@ -24,7 +24,11 @@
} else {
region.contains(1,1);
}
- auto s = SkSurface::MakeRasterN32Premul(1024, 1024);
+ auto s = SkSurface::MakeRasterN32Premul(128, 128);
+ if (!s) {
+ // May return nullptr in memory-constrained fuzzing environments
+ return false;
+ }
s->getCanvas()->drawRegion(region, SkPaint());
SkDEBUGCODE(region.validate());
return true;