Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: src/core/SkBitmap.cpp

Issue 83343003: Adding more validation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixed comments Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkImageFilter.h ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 int height = buffer.readInt(); 1615 int height = buffer.readInt();
1616 int rowBytes = buffer.readInt(); 1616 int rowBytes = buffer.readInt();
1617 Config config = (Config)buffer.readInt(); 1617 Config config = (Config)buffer.readInt();
1618 SkAlphaType alphaType = (SkAlphaType)buffer.readInt(); 1618 SkAlphaType alphaType = (SkAlphaType)buffer.readInt();
1619 buffer.validate((width >= 0) && (height >= 0) && (rowBytes >= 0) && 1619 buffer.validate((width >= 0) && (height >= 0) && (rowBytes >= 0) &&
1620 SkIsValidConfig(config) && validate_alphaType(config, alphaT ype)); 1620 SkIsValidConfig(config) && validate_alphaType(config, alphaT ype));
1621 1621
1622 this->setConfig(config, width, height, rowBytes, alphaType); 1622 this->setConfig(config, width, height, rowBytes, alphaType);
1623 1623
1624 int reftype = buffer.readInt(); 1624 int reftype = buffer.readInt();
1625 switch (reftype) { 1625 if (buffer.validate((SERIALIZE_PIXELTYPE_REF_DATA == reftype) ||
1626 case SERIALIZE_PIXELTYPE_REF_DATA: { 1626 (SERIALIZE_PIXELTYPE_NONE == reftype))) {
1627 size_t offset = buffer.readUInt(); 1627 switch (reftype) {
1628 SkPixelRef* pr = buffer.readPixelRef(); 1628 case SERIALIZE_PIXELTYPE_REF_DATA: {
1629 SkSafeUnref(this->setPixelRef(pr, offset)); 1629 size_t offset = buffer.readUInt();
1630 break; 1630 SkPixelRef* pr = buffer.readPixelRef();
1631 SkSafeUnref(this->setPixelRef(pr, offset));
1632 break;
1633 }
1634 case SERIALIZE_PIXELTYPE_NONE:
1635 break;
1636 default:
1637 SkDEBUGFAIL("unrecognized pixeltype in serialized data");
1638 sk_throw();
1631 } 1639 }
1632 case SERIALIZE_PIXELTYPE_NONE:
1633 break;
1634 default:
1635 buffer.validate(false);
1636 SkDEBUGFAIL("unrecognized pixeltype in serialized data");
1637 sk_throw();
1638 } 1640 }
1639 } 1641 }
1640 1642
1641 /////////////////////////////////////////////////////////////////////////////// 1643 ///////////////////////////////////////////////////////////////////////////////
1642 1644
1643 SkBitmap::RLEPixels::RLEPixels(int width, int height) { 1645 SkBitmap::RLEPixels::RLEPixels(int width, int height) {
1644 fHeight = height; 1646 fHeight = height;
1645 fYPtrs = (uint8_t**)sk_calloc_throw(height * sizeof(uint8_t*)); 1647 fYPtrs = (uint8_t**)sk_calloc_throw(height * sizeof(uint8_t*));
1646 } 1648 }
1647 1649
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 if (NULL != uri) { 1711 if (NULL != uri) {
1710 str->appendf(" uri:\"%s\"", uri); 1712 str->appendf(" uri:\"%s\"", uri);
1711 } else { 1713 } else {
1712 str->appendf(" pixelref:%p", pr); 1714 str->appendf(" pixelref:%p", pr);
1713 } 1715 }
1714 } 1716 }
1715 1717
1716 str->append(")"); 1718 str->append(")");
1717 } 1719 }
1718 #endif 1720 #endif
OLDNEW
« no previous file with comments | « include/core/SkImageFilter.h ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698