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

Unified Diff: src/images/SkImageDecoder_Factory.cpp

Issue 12545052: Fail to return a codec if the provided stream does not support rewind. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 9 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_Factory.cpp
diff --git a/src/images/SkImageDecoder_Factory.cpp b/src/images/SkImageDecoder_Factory.cpp
index 5640e0d9df90d5e53fbbaf01710733edfddf249b..c276a3d4ebe76048eac9b3798afa1360fce464b9 100644
--- a/src/images/SkImageDecoder_Factory.cpp
+++ b/src/images/SkImageDecoder_Factory.cpp
@@ -25,7 +25,16 @@ SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) {
codec = curr->factory()(stream);
// we rewind here, because we promise later when we call "decode", that
// the stream will be at its beginning.
- stream->rewind();
+ bool rewindSuceeded = stream->rewind();
+
+ // our image decoder's require that rewind is supported so we fail early
+ // if we are given a stream that does not support rewinding.
+ if (!rewindSuceeded) {
+ SkDEBUGF(("Unable to rewind the image stream."));
+ SkDELETE(codec);
+ return NULL;
+ }
+
if (codec) {
return codec;
}
« 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