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 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 this->reset(); | 1552 this->reset(); |
1553 | 1553 |
1554 int width = buffer.readInt(); | 1554 int width = buffer.readInt(); |
1555 int height = buffer.readInt(); | 1555 int height = buffer.readInt(); |
1556 int rowBytes = buffer.readInt(); | 1556 int rowBytes = buffer.readInt(); |
1557 Config config = (Config)buffer.readInt(); | 1557 Config config = (Config)buffer.readInt(); |
1558 SkAlphaType alphaType = (SkAlphaType)buffer.readInt(); | 1558 SkAlphaType alphaType = (SkAlphaType)buffer.readInt(); |
1559 buffer.validate((width >= 0) && (height >= 0) && (rowBytes >= 0) && | 1559 buffer.validate((width >= 0) && (height >= 0) && (rowBytes >= 0) && |
1560 SkIsValidConfig(config) && validate_alphaType(config, alphaT
ype)); | 1560 SkIsValidConfig(config) && validate_alphaType(config, alphaT
ype)); |
1561 | 1561 |
1562 this->setConfig(config, width, height, rowBytes, alphaType); | 1562 bool configIsValid = this->setConfig(config, width, height, rowBytes, alphaT
ype); |
1563 buffer.validate(fRowBytes >= (fWidth * fBytesPerPixel)); | 1563 // Note : Using (fRowBytes >= (fWidth * fBytesPerPixel)) in the following te
st can create false |
| 1564 // positives if the multiplication causes an integer overflow. Use th
e division instead. |
| 1565 buffer.validate(configIsValid && (fBytesPerPixel > 0) && |
| 1566 ((fRowBytes / fBytesPerPixel) >= fWidth)); |
1564 | 1567 |
1565 int reftype = buffer.readInt(); | 1568 int reftype = buffer.readInt(); |
1566 if (buffer.validate((SERIALIZE_PIXELTYPE_REF_DATA == reftype) || | 1569 if (buffer.validate((SERIALIZE_PIXELTYPE_REF_DATA == reftype) || |
1567 (SERIALIZE_PIXELTYPE_NONE == reftype))) { | 1570 (SERIALIZE_PIXELTYPE_NONE == reftype))) { |
1568 switch (reftype) { | 1571 switch (reftype) { |
1569 case SERIALIZE_PIXELTYPE_REF_DATA: { | 1572 case SERIALIZE_PIXELTYPE_REF_DATA: { |
1570 size_t offset = buffer.readUInt(); | 1573 size_t offset = buffer.readUInt(); |
1571 SkPixelRef* pr = buffer.readPixelRef(); | 1574 SkPixelRef* pr = buffer.readPixelRef(); |
1572 if (!buffer.validate((NULL == pr) || | 1575 if (!buffer.validate((NULL == pr) || |
1573 (pr->getAllocatedSizeInBytes() >= (offset + this->getSafe
Size())))) { | 1576 (pr->getAllocatedSizeInBytes() >= (offset + this->getSafe
Size())))) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 if (NULL != uri) { | 1659 if (NULL != uri) { |
1657 str->appendf(" uri:\"%s\"", uri); | 1660 str->appendf(" uri:\"%s\"", uri); |
1658 } else { | 1661 } else { |
1659 str->appendf(" pixelref:%p", pr); | 1662 str->appendf(" pixelref:%p", pr); |
1660 } | 1663 } |
1661 } | 1664 } |
1662 | 1665 |
1663 str->append(")"); | 1666 str->append(")"); |
1664 } | 1667 } |
1665 #endif | 1668 #endif |
OLD | NEW |