Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Unified Diff: src/images/SkImageDecoder_libwebp.cpp

Issue 22672003: Make WebP decoding independent of stream length. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libwebp.cpp
diff --git a/src/images/SkImageDecoder_libwebp.cpp b/src/images/SkImageDecoder_libwebp.cpp
index b0fa7f7053d36d7050dbbd3fd407fa1329bead06..4dba99f429e22a69603b2b1e90fadbe2b1538f31 100644
--- a/src/images/SkImageDecoder_libwebp.cpp
+++ b/src/images/SkImageDecoder_libwebp.cpp
@@ -203,31 +203,27 @@ 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);
- if (0 == bytesRead) {
+ bool success = true;
+ VP8StatusCode status = VP8_STATUS_SUSPENDED;
+ do {
+ const uint32_t bytes_to_read = WEBP_IDECODE_BUFFER_SZ;
scroggo 2013/08/08 18:44:24 bytesToRead
+ const size_t bytes_read = stream->read(input, bytes_to_read);
scroggo 2013/08/08 18:44:24 bytesRead
+ if (bytes_read == 0) {
scroggo 2013/08/08 18:44:24 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, bytes_read);
+ 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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698