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

Side by Side Diff: third_party/ktx/ktx.cpp

Issue 514603003: Fail gracefully for KTX files with width or height of zero. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove space Created 6 years, 3 months 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 | « no previous file | no next file » | 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 2014 Google Inc. 3 * Copyright 2014 Google Inc.
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 #include "ktx.h" 9 #include "ktx.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 249
250 // We don't support texture arrays 250 // We don't support texture arrays
251 if (fHeader.fNumberOfArrayElements > 1) { 251 if (fHeader.fNumberOfArrayElements > 1) {
252 return false; 252 return false;
253 } 253 }
254 254
255 // We don't support cube maps 255 // We don't support cube maps
256 if (fHeader.fNumberOfFaces > 1) { 256 if (fHeader.fNumberOfFaces > 1) {
257 return false; 257 return false;
258 } 258 }
259
260 // We don't support width and/or height <= 0
261 if (fHeader.fPixelWidth <= 0 || fHeader.fPixelHeight <= 0) {
262 return false;
263 }
259 } 264 }
260 265
261 // Make sure that we have enough bytes left for the key/value 266 // Make sure that we have enough bytes left for the key/value
262 // data according to what was said in the header. 267 // data according to what was said in the header.
263 if (bytesLeft < fHeader.fBytesOfKeyValueData) { 268 if (bytesLeft < fHeader.fBytesOfKeyValueData) {
264 return false; 269 return false;
265 } 270 }
266 271
267 // Next read the key value pairs 272 // Next read the key value pairs
268 size_t keyValueBytesRead = 0; 273 size_t keyValueBytesRead = 0;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 for (int i = 0; i < height; ++i) { 550 for (int i = 0; i < height; ++i) {
546 if (!stream->write(rowPtr, bpp*width)) { 551 if (!stream->write(rowPtr, bpp*width)) {
547 return false; 552 return false;
548 } 553 }
549 rowPtr += bitmap.rowBytes(); 554 rowPtr += bitmap.rowBytes();
550 } 555 }
551 } 556 }
552 557
553 return true; 558 return true;
554 } 559 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698