if (skia_enable_discrete_gpu) {
defines += [ "SK_ENABLE_DISCRETE_GPU" ]
}
+ if (is_fuzzing) {
+ defines += [ "IS_FUZZING" ]
+ }
}
# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
#include "SkImageEncoder.h"
#include "SkMallocPixelRef.h"
#include "SkPath.h"
+#include "SkRegion.h"
+#include "SkSurface.h"
#include "SkOSFile.h"
#include "SkOSPath.h"
#include "SkPicture.h"
static void fuzz_icc(sk_sp<SkData>);
static void fuzz_img(sk_sp<SkData>, uint8_t, uint8_t);
static void fuzz_path_deserialize(sk_sp<SkData>);
+static void fuzz_region_deserialize(sk_sp<SkData>);
static void fuzz_skp(sk_sp<SkData>);
#if SK_SUPPORT_GPU
static void fuzz_sksl2glsl(sk_sp<SkData>);
fuzz_path_deserialize(bytes);
return 0;
}
+ if (0 == strcmp("region_deserialize", FLAGS_type[0])) {
+ fuzz_region_deserialize(bytes);
+ return 0;
+ }
if (0 == strcmp("skp", FLAGS_type[0])) {
fuzz_skp(bytes);
return 0;
SkDebugf("[terminated] Success! Initialized SkPath.\n");
}
+static void fuzz_region_deserialize(sk_sp<SkData> bytes) {
+ SkRegion region;
+ if (!region.readFromMemory(bytes->data(), bytes->size())) {
+ SkDebugf("[terminated] Couldn't initialize SkRegion.\n");
+ return;
+ }
+ region.computeRegionComplexity();
+ region.isComplex();
+ SkRegion r2;
+ if (region == r2) {
+ region.contains(0,0);
+ } else {
+ region.contains(1,1);
+ }
+ auto s = SkSurface::MakeRasterN32Premul(1024, 1024);
+ s->getCanvas()->drawRegion(region, SkPaint());
+ SkDEBUGCODE(region.validate());
+ SkDebugf("[terminated] Success! Initialized SkRegion.\n");
+}
+
#if SK_SUPPORT_GPU
static void fuzz_sksl2glsl(sk_sp<SkData> bytes) {
SkSL::Compiler compiler;
static inline void sk_out_of_memory(size_t size) {
SK_DEBUGFAILF("sk_out_of_memory (asked for " SK_SIZE_T_SPECIFIER " bytes)",
size);
+#if defined(IS_FUZZING)
+ exit(1);
+#else
abort();
+#endif
}
static inline void* throw_on_failure(size_t size, void* p) {
#endif
#if defined(SK_DEBUG) && defined(SK_BUILD_FOR_WIN)
__debugbreak();
+#endif
+#if defined(IS_FUZZING)
+ exit(1);
#else
abort();
#endif
void sk_out_of_memory(void) {
SkDEBUGFAIL("sk_out_of_memory");
+#if defined(IS_FUZZING)
+ exit(1);
+#else
abort();
+#endif
}
void* sk_malloc_throw(size_t size) {