SkPDFStream** fontStream) {
int ttcIndex;
std::unique_ptr<SkStream> fontData(typeface->openStream(&ttcIndex));
- SkASSERT(fontData.get());
+ SkASSERT(fontData);
+ if (!fontData) {
+ return 0;
+ }
size_t fontSize = fontData->getLength();
typeface(),
*subset,
&rawStream);
+ if (0 == fontSize) {
+ return false;
+ }
if (rawStream) {
fontStream.reset(rawStream);
fontStream->insertInt("Length1", fontSize);
std::unique_ptr<SkStreamAsset> fontData(
this->typeface()->openStream(nullptr));
SkASSERT(fontData);
+ if (!fontData || 0 == fontData->getLength()) {
+ return false;
+ }
fontSize = fontData->getLength();
SkASSERT(fontSize > 0);
fontStream.reset(new SkPDFSharedStream(fontData.release()));
}
case SkAdvancedTypefaceMetrics::kCFF_Font:
case SkAdvancedTypefaceMetrics::kType1CID_Font: {
+ std::unique_ptr<SkStreamAsset> fontData(
+ this->typeface()->openStream(nullptr));
+ SkASSERT(fontData);
+ SkASSERT(fontData->getLength() > 0);
+ if (!fontData || 0 == fontData->getLength()) {
+ return false;
+ }
sk_sp<SkPDFSharedStream> fontStream(
- new SkPDFSharedStream(this->typeface()->openStream(nullptr)));
-
+ new SkPDFSharedStream(fontData.release()));
if (getType() == SkAdvancedTypefaceMetrics::kCFF_Font) {
fontStream->dict()->insertName("Subtype", "Type1C");
} else {
size_t header SK_INIT_TO_AVOID_WARNING;
size_t data SK_INIT_TO_AVOID_WARNING;
size_t trailer SK_INIT_TO_AVOID_WARNING;
- std::unique_ptr<SkStream> rawFontData(typeface()->openStream(&ttcIndex));
+ std::unique_ptr<SkStreamAsset> rawFontData(typeface()->openStream(&ttcIndex));
+ SkASSERT(rawFontData);
+ SkASSERT(rawFontData->getLength() > 0);
+ if (!rawFontData || 0 == rawFontData->getLength()) {
+ return false;
+ }
sk_sp<SkData> fontData(handle_type1_stream(rawFontData.get(), &header,
&data, &trailer));
if (fontData.get() == nullptr) {