summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform')
-rw-r--r--Source/WebCore/platform/graphics/FloatRect.cpp16
-rw-r--r--Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp4
-rw-r--r--Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp4
-rw-r--r--Source/WebCore/platform/mac/HTMLConverter.mm3
4 files changed, 12 insertions, 15 deletions
diff --git a/Source/WebCore/platform/graphics/FloatRect.cpp b/Source/WebCore/platform/graphics/FloatRect.cpp
index 165ef76..7afc92b 100644
--- a/Source/WebCore/platform/graphics/FloatRect.cpp
+++ b/Source/WebCore/platform/graphics/FloatRect.cpp
@@ -182,18 +182,6 @@ void FloatRect::fitToPoints(const FloatPoint& p0, const FloatPoint& p1, const Fl
setLocationAndSizeFromEdges(left, top, right, bottom);
}
-static inline int safeFloatToInt(float x)
-{
- static const int s_intMax = std::numeric_limits<int>::max();
- static const int s_intMin = std::numeric_limits<int>::min();
-
- if (x >= static_cast<float>(s_intMax))
- return s_intMax;
- if (x < static_cast<float>(s_intMin))
- return s_intMin;
- return static_cast<int>(x);
-}
-
IntRect enclosingIntRect(const FloatRect& rect)
{
float left = floorf(rect.x());
@@ -201,8 +189,8 @@ IntRect enclosingIntRect(const FloatRect& rect)
float width = ceilf(rect.maxX()) - left;
float height = ceilf(rect.maxY()) - top;
- return IntRect(safeFloatToInt(left), safeFloatToInt(top),
- safeFloatToInt(width), safeFloatToInt(height));
+ return IntRect(clampToInteger(left), clampToInteger(top),
+ clampToInteger(width), clampToInteger(height));
}
FloatRect mapRect(const FloatRect& r, const FloatRect& srcRect, const FloatRect& destRect)
diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp
index f067b66..08652c9 100644
--- a/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp
@@ -110,6 +110,10 @@ static void premultitplyScanline(void* data, size_t tileNumber)
PassRefPtr<ByteArray> ImageBufferData::getData(const IntRect& rect, const IntSize& size, bool accelerateRendering, bool unmultiplied) const
{
+ float area = 4.0f * rect.width() * rect.height();
+ if (area > static_cast<float>(std::numeric_limits<int>::max()))
+ return 0;
+
RefPtr<ByteArray> result = ByteArray::create(rect.width() * rect.height() * 4);
unsigned char* data = result->data();
diff --git a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
index 2352672..2a1738a 100644
--- a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
+++ b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
@@ -168,6 +168,10 @@ template <Multiply multiplied>
PassRefPtr<ByteArray> getImageData(const IntRect& rect, SkDevice& srcDevice,
const IntSize& size)
{
+ float area = 4.0f * rect.width() * rect.height();
+ if (area > static_cast<float>(std::numeric_limits<int>::max()))
+ return 0;
+
RefPtr<ByteArray> result = ByteArray::create(rect.width() * rect.height() * 4);
SkBitmap::Config srcConfig = srcDevice.accessBitmap(false).config();
diff --git a/Source/WebCore/platform/mac/HTMLConverter.mm b/Source/WebCore/platform/mac/HTMLConverter.mm
index c0b0ba2..80016fd 100644
--- a/Source/WebCore/platform/mac/HTMLConverter.mm
+++ b/Source/WebCore/platform/mac/HTMLConverter.mm
@@ -1753,7 +1753,8 @@ static NSFileWrapper *fileWrapperForElement(Element* element)
const AtomicString& attr = element->getAttribute(srcAttr);
if (!attr.isEmpty()) {
NSURL *URL = element->document()->completeURL(attr);
- wrapper = fileWrapperForURL(element->document()->loader(), URL);
+ if (DocumentLoader* loader = element->document()->loader())
+ wrapper = fileWrapperForURL(loader, URL);
}
if (!wrapper) {
RenderImage* renderer = toRenderImage(element->renderer());