2020-06-10 12:38:27 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2020 Google, LLC
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2020-06-10 12:45:35 +00:00
|
|
|
#include "experimental/svg/model/SkSVGDOM.h"
|
2020-06-10 12:33:48 +00:00
|
|
|
#include "include/core/SkData.h"
|
|
|
|
#include "include/core/SkStream.h"
|
2020-06-11 16:51:33 +00:00
|
|
|
#include "include/core/SkSurface.h"
|
|
|
|
|
2020-06-10 12:33:48 +00:00
|
|
|
void FuzzSVG(sk_sp<SkData> bytes) {
|
2020-06-12 11:54:04 +00:00
|
|
|
uint8_t w = 100;
|
|
|
|
uint8_t h = 200;
|
2020-06-11 16:51:33 +00:00
|
|
|
|
2020-06-10 12:33:48 +00:00
|
|
|
SkMemoryStream stream(bytes);
|
2020-06-11 16:51:33 +00:00
|
|
|
sk_sp<SkSVGDOM> dom = SkSVGDOM::MakeFromStream(stream);
|
2020-06-10 12:33:48 +00:00
|
|
|
if (!dom) {
|
|
|
|
return;
|
|
|
|
}
|
2020-06-11 16:51:33 +00:00
|
|
|
|
|
|
|
auto s = SkSurface::MakeRasterN32Premul(128, 128);
|
|
|
|
if (!s) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SkSize winSize = SkSize::Make(w, h);
|
|
|
|
dom->setContainerSize(winSize);
|
2020-06-12 11:54:04 +00:00
|
|
|
dom->containerSize();
|
2020-06-11 16:51:33 +00:00
|
|
|
dom->render(s->getCanvas());
|
|
|
|
|
2020-06-10 12:33:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(IS_FUZZING_WITH_LIBFUZZER)
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
2020-06-12 19:30:37 +00:00
|
|
|
if (size > 30000) {
|
|
|
|
return 0;
|
|
|
|
}
|
2020-06-10 12:33:48 +00:00
|
|
|
auto bytes = SkData::MakeWithoutCopy(data, size);
|
|
|
|
FuzzSVG(bytes);
|
|
|
|
return 0;
|
|
|
|
}
|
2020-06-11 16:56:04 +00:00
|
|
|
#endif
|