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

Unified Diff: src/core/SkConvolver.cpp

Issue 1368393003: add hard-coded limit for tmp allocations when HQ image scaling (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update dox Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkConvolver.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkConvolver.cpp
diff --git a/src/core/SkConvolver.cpp b/src/core/SkConvolver.cpp
index 3a088aa034d3962059ca25a6866e5b6df6db4227..72deeaf2b7975d52c83554abfee74b8e294ee1cb 100644
--- a/src/core/SkConvolver.cpp
+++ b/src/core/SkConvolver.cpp
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "SkConvolver.h"
+#include "SkMath.h"
#include "SkSize.h"
#include "SkTypes.h"
@@ -358,7 +359,7 @@ const SkConvolutionFilter1D::ConvolutionFixed* SkConvolutionFilter1D::GetSingleF
return &fFilterValues[filter.fDataLocation];
}
-void BGRAConvolve2D(const unsigned char* sourceData,
+bool BGRAConvolve2D(const unsigned char* sourceData,
int sourceByteRowStride,
bool sourceHasAlpha,
const SkConvolutionFilter1D& filterX,
@@ -393,6 +394,20 @@ void BGRAConvolve2D(const unsigned char* sourceData,
int rowBufferWidth = (filterX.numValues() + 15) & ~0xF;
int rowBufferHeight = maxYFilterSize +
(convolveProcs.fConvolve4RowsHorizontally ? 4 : 0);
+
+ // check for too-big allocation requests : crbug.com/528628
+ {
+ int64_t size = sk_64_mul(rowBufferWidth, rowBufferHeight);
+ // need some limit, to avoid over-committing success from malloc, but then
+ // crashing when we try to actually use the memory.
+ // 100meg seems big enough to allow "normal" zoom factors and image sizes through
+ // while avoiding the crash seen by the bug (crbug.com/528628)
+ if (size > 100 * 1024 * 1024) {
+// SkDebugf("BGRAConvolve2D: tmp allocation [%lld] too big\n", size);
+ return false;
+ }
+ }
+
CircularRowBuffer rowBuffer(rowBufferWidth,
rowBufferHeight,
filterOffset);
@@ -486,4 +501,5 @@ void BGRAConvolve2D(const unsigned char* sourceData,
sourceHasAlpha);
}
}
+ return true;
}
« no previous file with comments | « src/core/SkConvolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698