Chromium Code Reviews| 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 buffer.validate(this->setConfig(config, width, height, rowBytes, alphaType)) ; |
|
Stephen White
2013/12/05 20:48:22
Nit: this might be clearer if the result of setCon
| |
| 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((fBytesPerPixel > 0) && ((fRowBytes / fBytesPerPixel) >= fWi dth)); | |
| 1564 | 1566 |
| 1565 int reftype = buffer.readInt(); | 1567 int reftype = buffer.readInt(); |
| 1566 if (buffer.validate((SERIALIZE_PIXELTYPE_REF_DATA == reftype) || | 1568 if (buffer.validate((SERIALIZE_PIXELTYPE_REF_DATA == reftype) || |
| 1567 (SERIALIZE_PIXELTYPE_NONE == reftype))) { | 1569 (SERIALIZE_PIXELTYPE_NONE == reftype))) { |
| 1568 switch (reftype) { | 1570 switch (reftype) { |
| 1569 case SERIALIZE_PIXELTYPE_REF_DATA: { | 1571 case SERIALIZE_PIXELTYPE_REF_DATA: { |
| 1570 size_t offset = buffer.readUInt(); | 1572 size_t offset = buffer.readUInt(); |
| 1571 SkPixelRef* pr = buffer.readPixelRef(); | 1573 SkPixelRef* pr = buffer.readPixelRef(); |
| 1572 if (!buffer.validate((NULL == pr) || | 1574 if (!buffer.validate((NULL == pr) || |
| 1573 (pr->getAllocatedSizeInBytes() >= (offset + this->getSafe Size())))) { | 1575 (pr->getAllocatedSizeInBytes() >= (offset + this->getSafe Size())))) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1656 if (NULL != uri) { | 1658 if (NULL != uri) { |
| 1657 str->appendf(" uri:\"%s\"", uri); | 1659 str->appendf(" uri:\"%s\"", uri); |
| 1658 } else { | 1660 } else { |
| 1659 str->appendf(" pixelref:%p", pr); | 1661 str->appendf(" pixelref:%p", pr); |
| 1660 } | 1662 } |
| 1661 } | 1663 } |
| 1662 | 1664 |
| 1663 str->append(")"); | 1665 str->append(")"); |
| 1664 } | 1666 } |
| 1665 #endif | 1667 #endif |
| OLD | NEW |