diff options
author | Brian Osman <brianosman@google.com> | 2016-11-29 15:10:13 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-29 20:47:37 +0000 |
commit | 06826d9d204b88c4c33ad53c823ccbca8dee60f7 (patch) | |
tree | abdb8eda18b30d4944ef5e0dddfdbfcfc9fc9f25 /tools | |
parent | 79252f7997f2f5b90a72d2c7bd5f6aa8a58ee640 (diff) |
In GetResourceAsBitmap, don't crash if the resource is missing
NewFromEncoded returns nullptr if the resourceData is null or empty.
BUG=skia:
Change-Id: I8812b92b8664ebf5e5cf5cdd8b3bfb29963ed454
Reviewed-on: https://skia-review.googlesource.com/5314
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Resources.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/Resources.cpp b/tools/Resources.cpp index 981bfba337..0c6e4b4adf 100644 --- a/tools/Resources.cpp +++ b/tools/Resources.cpp @@ -30,6 +30,9 @@ bool GetResourceAsBitmap(const char* resource, SkBitmap* dst) { SkString resourcePath = GetResourcePath(resource); sk_sp<SkData> resourceData(SkData::MakeFromFileName(resourcePath.c_str())); std::unique_ptr<SkImageGenerator> gen(SkImageGenerator::NewFromEncoded(resourceData.get())); + if (!gen) { + return false; + } SkPMColor ctStorage[256]; sk_sp<SkColorTable> ctable(new SkColorTable(ctStorage, 256)); int count = ctable->count(); |