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

Side by Side Diff: src/effects/SkMatrixConvolutionImageFilter.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 | « src/effects/SkMagnifierImageFilter.cpp ('k') | src/effects/SkMergeImageFilter.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 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 "SkMatrixConvolutionImageFilter.h" 8 #include "SkMatrixConvolutionImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 fConvolveAlpha(convolveAlpha) { 51 fConvolveAlpha(convolveAlpha) {
52 uint32_t size = fKernelSize.fWidth * fKernelSize.fHeight; 52 uint32_t size = fKernelSize.fWidth * fKernelSize.fHeight;
53 fKernel = SkNEW_ARRAY(SkScalar, size); 53 fKernel = SkNEW_ARRAY(SkScalar, size);
54 memcpy(fKernel, kernel, size * sizeof(SkScalar)); 54 memcpy(fKernel, kernel, size * sizeof(SkScalar));
55 SkASSERT(kernelSize.fWidth >= 1 && kernelSize.fHeight >= 1); 55 SkASSERT(kernelSize.fWidth >= 1 && kernelSize.fHeight >= 1);
56 SkASSERT(target.fX >= 0 && target.fX < kernelSize.fWidth); 56 SkASSERT(target.fX >= 0 && target.fX < kernelSize.fWidth);
57 SkASSERT(target.fY >= 0 && target.fY < kernelSize.fHeight); 57 SkASSERT(target.fY >= 0 && target.fY < kernelSize.fHeight);
58 } 58 }
59 59
60 SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkFlattenableRead Buffer& buffer) 60 SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkFlattenableRead Buffer& buffer)
61 : INHERITED(buffer) { 61 : INHERITED(1, buffer) {
62 // We need to be able to read at most SK_MaxS32 bytes, so divide that 62 // We need to be able to read at most SK_MaxS32 bytes, so divide that
63 // by the size of a scalar to know how many scalars we can read. 63 // by the size of a scalar to know how many scalars we can read.
64 static const int32_t kMaxSize = SK_MaxS32 / sizeof(SkScalar); 64 static const int32_t kMaxSize = SK_MaxS32 / sizeof(SkScalar);
65 fKernelSize.fWidth = buffer.readInt(); 65 fKernelSize.fWidth = buffer.readInt();
66 fKernelSize.fHeight = buffer.readInt(); 66 fKernelSize.fHeight = buffer.readInt();
67 if ((fKernelSize.fWidth >= 1) && (fKernelSize.fHeight >= 1) && 67 if ((fKernelSize.fWidth >= 1) && (fKernelSize.fHeight >= 1) &&
68 // Make sure size won't be larger than a signed int, 68 // Make sure size won't be larger than a signed int,
69 // which would still be extremely large for a kernel, 69 // which would still be extremely large for a kernel,
70 // but we don't impose a hard limit for kernel size 70 // but we don't impose a hard limit for kernel size
71 (kMaxSize / fKernelSize.fWidth >= fKernelSize.fHeight)) { 71 (kMaxSize / fKernelSize.fWidth >= fKernelSize.fHeight)) {
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 fBias, 657 fBias,
658 fTarget, 658 fTarget,
659 fTileMode, 659 fTileMode,
660 fConvolveAlpha); 660 fConvolveAlpha);
661 return true; 661 return true;
662 } 662 }
663 663
664 /////////////////////////////////////////////////////////////////////////////// 664 ///////////////////////////////////////////////////////////////////////////////
665 665
666 #endif 666 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMagnifierImageFilter.cpp ('k') | src/effects/SkMergeImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698