Index: src/codec/SkJpegCodec.cpp |
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp |
index 6e2fc84ec8b58983bdc2b5ff5311171149f862f9..6ea13b7639dd560d9e06d5b490f26be267616e46 100644 |
--- a/src/codec/SkJpegCodec.cpp |
+++ b/src/codec/SkJpegCodec.cpp |
@@ -23,11 +23,9 @@ extern "C" { |
#include "jpeglib.h" |
} |
-bool SkJpegCodec::IsJpeg(SkStream* stream) { |
+bool SkJpegCodec::IsJpeg(const void* buffer, size_t bytesRead) { |
static const uint8_t jpegSig[] = { 0xFF, 0xD8, 0xFF }; |
- char buffer[sizeof(jpegSig)]; |
- return stream->read(buffer, sizeof(jpegSig)) == sizeof(jpegSig) && |
- !memcmp(buffer, jpegSig, sizeof(jpegSig)); |
+ return bytesRead >= 3 && !memcmp(buffer, jpegSig, sizeof(jpegSig)); |
} |
bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut, |