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

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

Issue 1091043003: Ensure that we create a NULL codec for images with zero dimensions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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 | « resources/empty_images/zero-width.wbmp ('k') | tests/CodexTest.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 * 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 "SkCodec_libbmp.h" 8 #include "SkCodec_libbmp.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 RowOrder rowOrder = kBottomUp_RowOrder; 312 RowOrder rowOrder = kBottomUp_RowOrder;
313 if (height < 0) { 313 if (height < 0) {
314 height = -height; 314 height = -height;
315 rowOrder = kTopDown_RowOrder; 315 rowOrder = kTopDown_RowOrder;
316 } 316 }
317 // The height field for bmp in ico is double the actual height because they 317 // The height field for bmp in ico is double the actual height because they
318 // contain an XOR mask followed by an AND mask 318 // contain an XOR mask followed by an AND mask
319 if (isIco) { 319 if (isIco) {
320 height /= 2; 320 height /= 2;
321 } 321 }
322 static const int kBmpMaxDim = 1 << 16; 322 if (width <= 0 || height <= 0) {
323 if (width < 0 || width >= kBmpMaxDim || height >= kBmpMaxDim) { 323 // TODO: Decide if we want to disable really large bmps as well.
324 // TODO: Decide if we want to support really large bmps. 324 // https://code.google.com/p/skia/issues/detail?id=3617
325 SkCodecPrintf("Error: invalid bitmap dimensions.\n"); 325 SkCodecPrintf("Error: invalid bitmap dimensions.\n");
326 return false; 326 return false;
327 } 327 }
328 328
329 // Create mask struct 329 // Create mask struct
330 SkMasks::InputMasks inputMasks; 330 SkMasks::InputMasks inputMasks;
331 memset(&inputMasks, 0, sizeof(SkMasks::InputMasks)); 331 memset(&inputMasks, 0, sizeof(SkMasks::InputMasks));
332 332
333 // Determine the input compression format and set bit masks if necessary 333 // Determine the input compression format and set bit masks if necessary
334 uint32_t maskBytes = 0; 334 uint32_t maskBytes = 0;
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 uint32_t alphaBit = 1229 uint32_t alphaBit =
1230 (srcBuffer.get()[quotient] >> shift) & 0x1; 1230 (srcBuffer.get()[quotient] >> shift) & 0x1;
1231 dstRow[x] &= alphaBit - 1; 1231 dstRow[x] &= alphaBit - 1;
1232 } 1232 }
1233 } 1233 }
1234 } 1234 }
1235 1235
1236 // Finished decoding the entire image 1236 // Finished decoding the entire image
1237 return kSuccess; 1237 return kSuccess;
1238 } 1238 }
OLDNEW
« no previous file with comments | « resources/empty_images/zero-width.wbmp ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698