diff options
author | djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-20 20:16:20 +0000 |
---|---|---|
committer | djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-20 20:16:20 +0000 |
commit | 50166524abd948f6288089c572cf125d2b4827a7 (patch) | |
tree | c3187f9509db8575190276f8bc837a3ef7637e0d /src | |
parent | 0f2cd172af30f9047acb493e56dddbc50a0c3dcd (diff) |
Fail to return a codec if the provided stream does not support rewind.
Review URL: https://codereview.chromium.org/12545052
git-svn-id: http://skia.googlecode.com/svn/trunk@8277 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/images/SkImageDecoder_Factory.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/images/SkImageDecoder_Factory.cpp b/src/images/SkImageDecoder_Factory.cpp index 5640e0d9df..c276a3d4eb 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; } |