Add test for old font axis deserialization.
Minimized from fuzzer case (rr is amazing). Verified that this test
failed before the fix 712d3a57e
"Cannot create SkFontData with no data."
and now succeeds with the fix.
Bug: oss-fuzz:26254
Change-Id: I985ba3ab61e5824d6a61ede04880692ecc69ce44
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327916
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
8aa0edfed2
commit
f9c7b28034
@ -149,6 +149,28 @@ DEF_TEST(FontDescriptorNegativeVariationSerialize, reporter) {
|
||||
REPORTER_ASSERT(reporter, descD.getVariation()[0].value == -1.0f);
|
||||
};
|
||||
|
||||
DEF_TEST(FontDescriptorDeserializeOldFormat, reporter) {
|
||||
// From ossfuzz:26254
|
||||
const uint8_t old_serialized_desc[] = {
|
||||
0x0, //style
|
||||
0xff, 0xfb, 0x0, 0x0, 0x0, // kFontAxes
|
||||
0x0, // coordinateCount
|
||||
0xff, 0xff, 0x0, 0x0, 0x0, // kSentinel
|
||||
0x0, // data length
|
||||
};
|
||||
|
||||
SkMemoryStream stream(old_serialized_desc, sizeof(old_serialized_desc), false);
|
||||
SkFontDescriptor desc;
|
||||
if (!SkFontDescriptor::Deserialize(&stream, &desc)) {
|
||||
REPORT_FAILURE(reporter, "!SkFontDescriptor::Deserialize(&stream, &desc)",
|
||||
SkString("bytes should be recognized unless removing support"));
|
||||
return;
|
||||
}
|
||||
// This call should not crash and should not return a valid SkFontData.
|
||||
std::unique_ptr<SkFontData> data = desc.maybeAsSkFontData();
|
||||
REPORTER_ASSERT(reporter, !data);
|
||||
};
|
||||
|
||||
DEF_TEST(TypefaceAxes, reporter) {
|
||||
std::unique_ptr<SkStreamAsset> distortable(GetResourceAsStream("fonts/Distortable.ttf"));
|
||||
if (!distortable) {
|
||||
|
Loading…
Reference in New Issue
Block a user