OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1198 | 1198 |
1199 // If there was an error reading "info", don't use it to compute minRowBytes () | 1199 // If there was an error reading "info", don't use it to compute minRowBytes () |
1200 if (!buffer->validate(true)) { | 1200 if (!buffer->validate(true)) { |
1201 return false; | 1201 return false; |
1202 } | 1202 } |
1203 | 1203 |
1204 const size_t ramRB = info.minRowBytes(); | 1204 const size_t ramRB = info.minRowBytes(); |
1205 const int height = info.height(); | 1205 const int height = info.height(); |
1206 const size_t snugSize = snugRB * height; | 1206 const size_t snugSize = snugRB * height; |
1207 const size_t ramSize = ramRB * height; | 1207 const size_t ramSize = ramRB * height; |
1208 if (!buffer->validate(snugSize <= ramSize)) { | 1208 if (!buffer->validate((snugSize <= ramSize) && ((ramSize / ramRB) == height) )) { |
reed1
2015/01/06 22:29:34
perhaps we can explicitly use int64_t. We have han
| |
1209 return false; | 1209 return false; |
1210 } | 1210 } |
1211 | 1211 |
1212 SkAutoDataUnref data(SkData::NewUninitialized(ramSize)); | 1212 SkAutoDataUnref data(SkData::NewUninitialized(ramSize)); |
1213 char* dst = (char*)data->writable_data(); | 1213 char* dst = (char*)data->writable_data(); |
1214 buffer->readByteArray(dst, snugSize); | 1214 buffer->readByteArray(dst, snugSize); |
1215 | 1215 |
1216 if (snugSize != ramSize) { | 1216 if (snugSize != ramSize) { |
1217 const char* srcRow = dst + snugRB * (height - 1); | 1217 const char* srcRow = dst + snugRB * (height - 1); |
1218 char* dstRow = dst + ramRB * (height - 1); | 1218 char* dstRow = dst + ramRB * (height - 1); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1378 /////////////////////////////////////////////////////////////////////////////// | 1378 /////////////////////////////////////////////////////////////////////////////// |
1379 | 1379 |
1380 #ifdef SK_DEBUG | 1380 #ifdef SK_DEBUG |
1381 void SkImageInfo::validate() const { | 1381 void SkImageInfo::validate() const { |
1382 SkASSERT(fWidth >= 0); | 1382 SkASSERT(fWidth >= 0); |
1383 SkASSERT(fHeight >= 0); | 1383 SkASSERT(fHeight >= 0); |
1384 SkASSERT(SkColorTypeIsValid(fColorType)); | 1384 SkASSERT(SkColorTypeIsValid(fColorType)); |
1385 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1385 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
1386 } | 1386 } |
1387 #endif | 1387 #endif |
OLD | NEW |