Let SkWuffsCodec allow workbuf_len == 0

Some Wuffs actions don't require extra 'scratch space'.

Bug: skia:8235
Change-Id: Idcd2e1a8676b3b9f98dcff94ad1450d1e18a0401
Reviewed-on: https://skia-review.googlesource.com/c/187160
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
This commit is contained in:
Nigel Tao 2019-01-26 16:04:01 +11:00 committed by Skia Commit-Bot
parent 31a60dbd7b
commit 22e862430e

View File

@ -894,10 +894,13 @@ std::unique_ptr<SkCodec> SkWuffsCodec_MakeFromStream(std::unique_ptr<SkStream> s
}
uint64_t workbuf_len = decoder->workbuf_len().max_incl;
void* workbuf_ptr_raw = workbuf_len <= SIZE_MAX ? sk_malloc_canfail(workbuf_len) : nullptr;
if (!workbuf_ptr_raw) {
*result = SkCodec::kInternalError;
return nullptr;
void* workbuf_ptr_raw = nullptr;
if (workbuf_len) {
workbuf_ptr_raw = workbuf_len <= SIZE_MAX ? sk_malloc_canfail(workbuf_len) : nullptr;
if (!workbuf_ptr_raw) {
*result = SkCodec::kInternalError;
return nullptr;
}
}
std::unique_ptr<uint8_t, decltype(&sk_free)> workbuf_ptr(
reinterpret_cast<uint8_t*>(workbuf_ptr_raw), &sk_free);