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 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 this->setConfig(config, width, height, rowBytes, alphaType); |
| 1563 buffer.validate(fRowBytes >= (fWidth * fBytesPerPixel)); |
1563 | 1564 |
1564 int reftype = buffer.readInt(); | 1565 int reftype = buffer.readInt(); |
1565 if (buffer.validate((SERIALIZE_PIXELTYPE_REF_DATA == reftype) || | 1566 if (buffer.validate((SERIALIZE_PIXELTYPE_REF_DATA == reftype) || |
1566 (SERIALIZE_PIXELTYPE_NONE == reftype))) { | 1567 (SERIALIZE_PIXELTYPE_NONE == reftype))) { |
1567 switch (reftype) { | 1568 switch (reftype) { |
1568 case SERIALIZE_PIXELTYPE_REF_DATA: { | 1569 case SERIALIZE_PIXELTYPE_REF_DATA: { |
1569 size_t offset = buffer.readUInt(); | 1570 size_t offset = buffer.readUInt(); |
1570 SkPixelRef* pr = buffer.readPixelRef(); | 1571 SkPixelRef* pr = buffer.readPixelRef(); |
| 1572 if (!buffer.validate((NULL == pr) || |
| 1573 (pr->getSize() >= (offset + this->getSafeSize())))) { |
| 1574 offset = 0; |
| 1575 } |
1571 SkSafeUnref(this->setPixelRef(pr, offset)); | 1576 SkSafeUnref(this->setPixelRef(pr, offset)); |
1572 break; | 1577 break; |
1573 } | 1578 } |
1574 case SERIALIZE_PIXELTYPE_NONE: | 1579 case SERIALIZE_PIXELTYPE_NONE: |
1575 break; | 1580 break; |
1576 default: | 1581 default: |
1577 SkDEBUGFAIL("unrecognized pixeltype in serialized data"); | 1582 SkDEBUGFAIL("unrecognized pixeltype in serialized data"); |
1578 sk_throw(); | 1583 sk_throw(); |
1579 } | 1584 } |
1580 } | 1585 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 if (NULL != uri) { | 1656 if (NULL != uri) { |
1652 str->appendf(" uri:\"%s\"", uri); | 1657 str->appendf(" uri:\"%s\"", uri); |
1653 } else { | 1658 } else { |
1654 str->appendf(" pixelref:%p", pr); | 1659 str->appendf(" pixelref:%p", pr); |
1655 } | 1660 } |
1656 } | 1661 } |
1657 | 1662 |
1658 str->append(")"); | 1663 str->append(")"); |
1659 } | 1664 } |
1660 #endif | 1665 #endif |
OLD | NEW |