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

Unified Diff: src/images/SkImageDecoder_libico.cpp

Issue 23330002: Avoid getLength in ico decoder. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Respond to comments. 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 | « src/images/SkImageDecoder_libbmp.cpp ('k') | src/images/SkStreamHelpers.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libico.cpp
diff --git a/src/images/SkImageDecoder_libico.cpp b/src/images/SkImageDecoder_libico.cpp
index b14e19614ceca7c65ac4567c6983d4835c6d9844..47fa7293f0a54b5410d8f361da4a23577d468479 100644
--- a/src/images/SkImageDecoder_libico.cpp
+++ b/src/images/SkImageDecoder_libico.cpp
@@ -1,4 +1,3 @@
-
/*
* Copyright 2006 The Android Open Source Project
*
@@ -6,10 +5,10 @@
* found in the LICENSE file.
*/
-
+#include "SkColorPriv.h"
#include "SkImageDecoder.h"
#include "SkStream.h"
-#include "SkColorPriv.h"
+#include "SkStreamHelpers.h"
#include "SkTypes.h"
class SkICOImageDecoder : public SkImageDecoder {
@@ -75,13 +74,14 @@ static int calculateRowBytesFor8888(int w, int bitCount)
bool SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode)
{
- size_t length = stream->getLength();
- SkAutoMalloc autoMal(length);
- unsigned char* buf = (unsigned char*)autoMal.get();
- if (stream->read((void*)buf, length) != length) {
+ SkAutoMalloc autoMal;
+ const size_t length = CopyStreamToStorage(&autoMal, stream);
+ if (0 == length) {
return false;
}
+ unsigned char* buf = (unsigned char*)autoMal.get();
+
//these should always be the same - should i use for error checking? - what about files that have some
//incorrect values, but still decode properly?
int reserved = read2Bytes(buf, 0); // 0
« no previous file with comments | « src/images/SkImageDecoder_libbmp.cpp ('k') | src/images/SkStreamHelpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698