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

Side by Side Diff: src/codec/SkBmpCodec.cpp

Issue 1498923002: Fix overflow caught by ASAN. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Make variable const. Created 5 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
« no previous file with comments | « src/codec/SkBmpCodec.h ('k') | src/codec/SkBmpRLECodec.h » ('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 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBmpCodec.h" 8 #include "SkBmpCodec.h"
9 #include "SkBmpMaskCodec.h" 9 #include "SkBmpMaskCodec.h"
10 #include "SkBmpRLECodec.h" 10 #include "SkBmpRLECodec.h"
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 541 }
542 542
543 int32_t SkBmpCodec::getDstRow(int32_t y, int32_t height) const { 543 int32_t SkBmpCodec::getDstRow(int32_t y, int32_t height) const {
544 if (SkCodec::kTopDown_SkScanlineOrder == fRowOrder) { 544 if (SkCodec::kTopDown_SkScanlineOrder == fRowOrder) {
545 return y; 545 return y;
546 } 546 }
547 SkASSERT(SkCodec::kBottomUp_SkScanlineOrder == fRowOrder); 547 SkASSERT(SkCodec::kBottomUp_SkScanlineOrder == fRowOrder);
548 return height - y - 1; 548 return height - y - 1;
549 } 549 }
550 550
551 /*
552 * Compute the number of colors in the color table
553 */
554 uint32_t SkBmpCodec::computeNumColors(uint32_t numColors) {
555 // Zero is a default for maxColors
556 // Also set numColors to maxColors when it is too large
557 uint32_t maxColors = 1 << fBitsPerPixel;
558 if (numColors == 0 || numColors >= maxColors) {
559 return maxColors;
560 }
561 return numColors;
562 }
563
564 SkCodec::Result SkBmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, 551 SkCodec::Result SkBmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
565 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) { 552 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) {
566 if (!conversion_possible(dstInfo, this->getInfo())) { 553 if (!conversion_possible(dstInfo, this->getInfo())) {
567 SkCodecPrintf("Error: cannot convert input type to output type.\n"); 554 SkCodecPrintf("Error: cannot convert input type to output type.\n");
568 return kInvalidConversion; 555 return kInvalidConversion;
569 } 556 }
570 557
571 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount); 558 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount);
572 } 559 }
573 560
574 int SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { 561 int SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) {
575 // Create a new image info representing the portion of the image to decode 562 // Create a new image info representing the portion of the image to decode
576 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ; 563 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ;
577 564
578 // Decode the requested rows 565 // Decode the requested rows
579 return this->decodeRows(rowInfo, dst, rowBytes, this->options()); 566 return this->decodeRows(rowInfo, dst, rowBytes, this->options());
580 } 567 }
OLDNEW
« no previous file with comments | « src/codec/SkBmpCodec.h ('k') | src/codec/SkBmpRLECodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698