OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
9 #include "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
10 #include "SkStream.h" | 10 #include "SkStream.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 // promote the sum to 64-bits to avoid overflow | 157 // promote the sum to 64-bits to avoid overflow |
158 if (((uint64_t)offset + size) > length) { | 158 if (((uint64_t)offset + size) > length) { |
159 return false; | 159 return false; |
160 } | 160 } |
161 | 161 |
162 // Check to see if this is a PNG image inside the ICO | 162 // Check to see if this is a PNG image inside the ICO |
163 { | 163 { |
164 SkMemoryStream subStream(buf + offset, size, false); | 164 SkMemoryStream subStream(buf + offset, size, false); |
165 SkAutoTDelete<SkImageDecoder> otherDecoder(SkImageDecoder::Factory(&subS tream)); | 165 SkAutoTDelete<SkImageDecoder> otherDecoder(SkImageDecoder::Factory(&subS tream)); |
166 if (otherDecoder.get() != NULL) { | 166 if (otherDecoder.get() != NULL) { |
167 // Disallow nesting ICO files within one another | |
reed1
2014/08/26 17:53:34
Can we add a test case/data for this?
| |
168 if (otherDecoder->getFormat() == SkImageDecoder::kICO_Format) { | |
scroggo
2014/10/14 22:58:23
We could be more aggressive here; I think the only
| |
169 return false; | |
170 } | |
167 // Set fields on the other decoder to be the same as this one. | 171 // Set fields on the other decoder to be the same as this one. |
168 this->copyFieldsToOther(otherDecoder.get()); | 172 this->copyFieldsToOther(otherDecoder.get()); |
169 if(otherDecoder->decode(&subStream, bm, this->getDefaultPref(), mode )) { | 173 if(otherDecoder->decode(&subStream, bm, this->getDefaultPref(), mode )) { |
170 return true; | 174 return true; |
171 } | 175 } |
172 } | 176 } |
173 } | 177 } |
174 | 178 |
175 //int infoSize = read4Bytes(buf, offset); //40 | 179 //int infoSize = read4Bytes(buf, offset); //40 |
176 //int width = read4Bytes(buf, offset+4); //should == w | 180 //int width = read4Bytes(buf, offset+4); //should == w |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 static SkImageDecoder_DecodeReg gReg(sk_libico_dfactory); | 418 static SkImageDecoder_DecodeReg gReg(sk_libico_dfactory); |
415 | 419 |
416 static SkImageDecoder::Format get_format_ico(SkStreamRewindable* stream) { | 420 static SkImageDecoder::Format get_format_ico(SkStreamRewindable* stream) { |
417 if (is_ico(stream)) { | 421 if (is_ico(stream)) { |
418 return SkImageDecoder::kICO_Format; | 422 return SkImageDecoder::kICO_Format; |
419 } | 423 } |
420 return SkImageDecoder::kUnknown_Format; | 424 return SkImageDecoder::kUnknown_Format; |
421 } | 425 } |
422 | 426 |
423 static SkImageDecoder_FormatReg gFormatReg(get_format_ico); | 427 static SkImageDecoder_FormatReg gFormatReg(get_format_ico); |
OLD | NEW |