diff --git a/src/pdf/SkPDFSubsetFont.cpp b/src/pdf/SkPDFSubsetFont.cpp index 8d1605c44d..0bb92bb962 100644 --- a/src/pdf/SkPDFSubsetFont.cpp +++ b/src/pdf/SkPDFSubsetFont.cpp @@ -11,6 +11,7 @@ #include "include/private/SkTemplates.h" #include "include/private/SkTo.h" +#include "src/utils/SkCallableTraits.h" #include "hb.h" #include "hb-subset.h" @@ -22,7 +23,13 @@ using HBSubsetInput = resource; using HBSet = resource; static HBBlob to_blob(sk_sp data) { - return HBBlob(hb_blob_create((char*)data->data(), SkToUInt(data->size()), + using blob_size_t = SkCallableTraits::argument<1>::type; + if (!SkTFitsIn(data->size())) { + return nullptr; + } + const char* blobData = static_cast(data->data()); + blob_size_t blobSize = SkTo(data->size()); + return HBBlob(hb_blob_create(blobData, blobSize, HB_MEMORY_MODE_READONLY, data.release(), [](void* p){ ((SkData*)p)->unref(); })); }