aboutsummaryrefslogtreecommitdiffhomepage
path: root/fuzz/oss_fuzz/FuzzPathDeserialize.cpp
diff options
context:
space:
mode:
authorGravatar Kevin Lubick <kjlubick@google.com>2018-02-08 14:31:24 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-09 14:37:41 +0000
commitf034d118597dc346bfe7f327ea10a950a7c1e35d (patch)
tree20b045b8f381e29d2039f15bccecb33703f0cf52 /fuzz/oss_fuzz/FuzzPathDeserialize.cpp
parent67f8584b6f899876ca4187dba4f449ce5489f9c8 (diff)
Break some fuzzer targets out so oss-fuzz can use them
FuzzImageFilterDeserialize is already being used in oss-fuzz but the target lived there and not here. This moves it here. Then we can turn on: - FuzzPathDeserialize - FuzzTextBlobDeserialize Bug: skia: Change-Id: I7baee8386fb7aeebc43a68abfff9a670ba16f82c Reviewed-on: https://skia-review.googlesource.com/105763 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Kevin Lubick <kjlubick@google.com>
Diffstat (limited to 'fuzz/oss_fuzz/FuzzPathDeserialize.cpp')
-rw-r--r--fuzz/oss_fuzz/FuzzPathDeserialize.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/fuzz/oss_fuzz/FuzzPathDeserialize.cpp b/fuzz/oss_fuzz/FuzzPathDeserialize.cpp
new file mode 100644
index 0000000000..b18f719f4f
--- /dev/null
+++ b/fuzz/oss_fuzz/FuzzPathDeserialize.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkCanvas.h"
+#include "SkPaint.h"
+#include "SkPath.h"
+#include "SkReadBuffer.h"
+#include "SkSurface.h"
+
+void FuzzPathDeserialize(SkReadBuffer& buf) {
+ SkPath path;
+ buf.readPath(&path);
+ if (!buf.isValid()) {
+ return;
+ }
+
+ auto s = SkSurface::MakeRasterN32Premul(128, 128);
+ if (!s) {
+ // May return nullptr in memory-constrained fuzzing environments
+ return;
+ }
+ s->getCanvas()->drawPath(path, SkPaint());
+}
+
+#if defined(IS_FUZZING_WITH_LIBFUZZER)
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ SkReadBuffer buf(data, size);
+ FuzzPathDeserialize(buf);
+ return 0;
+}
+#endif