aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar jvanverth@google.com <jvanverth@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-09 14:24:30 +0000
committerGravatar jvanverth@google.com <jvanverth@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-09 14:24:30 +0000
commit1904df0413b9b665a5f8be7a4614abe5f2e30d21 (patch)
tree100e041c250d53d9c54d6dc14728e8c81f828d98 /src
parent9c1a967967e385a2c4c1607b8f997e72a18205be (diff)
Reverting r10651: Make WebP decoding independent of stream length.
git-svn-id: http://skia.googlecode.com/svn/trunk@10656 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/images/SkImageDecoder_libwebp.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/images/SkImageDecoder_libwebp.cpp b/src/images/SkImageDecoder_libwebp.cpp
index 4b5081b436..b0fa7f7053 100644
--- a/src/images/SkImageDecoder_libwebp.cpp
+++ b/src/images/SkImageDecoder_libwebp.cpp
@@ -203,27 +203,31 @@ static bool webp_idecode(SkStream* stream, WebPDecoderConfig* config) {
return false;
}
- bool success = true;
- VP8StatusCode status = VP8_STATUS_SUSPENDED;
- do {
- const uint32_t bytesToRead = WEBP_IDECODE_BUFFER_SZ;
+ uint32_t bytesRemaining = contentSize;
+ while (bytesRemaining > 0) {
+ const uint32_t bytesToRead = (bytesRemaining < WEBP_IDECODE_BUFFER_SZ) ?
+ bytesRemaining : WEBP_IDECODE_BUFFER_SZ;
const size_t bytesRead = stream->read(input, bytesToRead);
if (0 == bytesRead) {
- success = false;
break;
}
- status = WebPIAppend(idec, input, bytesRead);
- if (VP8_STATUS_OK != status && VP8_STATUS_SUSPENDED != status) {
- success = false;
+ VP8StatusCode status = WebPIAppend(idec, input, bytesRead);
+ if (VP8_STATUS_OK == status || VP8_STATUS_SUSPENDED == status) {
+ bytesRemaining -= bytesRead;
+ } else {
break;
}
- } while (VP8_STATUS_OK != status);
+ }
srcStorage.free();
WebPIDelete(idec);
WebPFreeDecBuffer(&config->output);
- return success;
+ if (bytesRemaining > 0) {
+ return false;
+ } else {
+ return true;
+ }
}
static bool webp_get_config_resize(WebPDecoderConfig* config,