Index: src/images/SkImageDecoder_libwebp.cpp |
diff --git a/src/images/SkImageDecoder_libwebp.cpp b/src/images/SkImageDecoder_libwebp.cpp |
index b0fa7f7053d36d7050dbbd3fd407fa1329bead06..4691d0d13eefd3a419edfd99d75b3f7b8ff9c610 100644 |
--- a/src/images/SkImageDecoder_libwebp.cpp |
+++ b/src/images/SkImageDecoder_libwebp.cpp |
@@ -203,31 +203,26 @@ static bool webp_idecode(SkStream* stream, WebPDecoderConfig* config) { |
return false; |
} |
- 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); |
+ bool success = true; |
+ VP8StatusCode status = VP8_STATUS_SUSPENDED; |
+ do { |
+ const size_t bytesRead = stream->read(input, readBufferSize); |
scroggo
2013/08/09 19:15:32
Patch set 2 has the fix - don't write beyond the s
|
if (0 == bytesRead) { |
+ success = false; |
break; |
} |
- VP8StatusCode status = WebPIAppend(idec, input, bytesRead); |
- if (VP8_STATUS_OK == status || VP8_STATUS_SUSPENDED == status) { |
- bytesRemaining -= bytesRead; |
- } else { |
+ status = WebPIAppend(idec, input, bytesRead); |
+ if (VP8_STATUS_OK != status && VP8_STATUS_SUSPENDED != status) { |
+ success = false; |
break; |
} |
- } |
+ } while (VP8_STATUS_OK != status); |
srcStorage.free(); |
WebPIDelete(idec); |
WebPFreeDecBuffer(&config->output); |
- if (bytesRemaining > 0) { |
- return false; |
- } else { |
- return true; |
- } |
+ return success; |
} |
static bool webp_get_config_resize(WebPDecoderConfig* config, |