f034d11859
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>
36 lines
809 B
C++
36 lines
809 B
C++
/*
|
|
* 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
|