Diff
Modified: trunk/Source/WebCore/ChangeLog (185765 => 185766)
--- trunk/Source/WebCore/ChangeLog 2015-06-19 20:40:11 UTC (rev 185765)
+++ trunk/Source/WebCore/ChangeLog 2015-06-19 20:45:54 UTC (rev 185766)
@@ -1,3 +1,32 @@
+2015-06-19 Brent Fulgham <[email protected]>
+
+ All calls of ImageBuffer::create should null check the return value
+ https://bugs.webkit.org/show_bug.cgi?id=22132
+
+ Reviewed by Zalan Bujtas.
+
+ ImageBuffer::create returns nullptr for a number of reasons, and should be
+ expected to do so. We missed this check in a few places, resulting in
+ crashes on some systems. Likewise, ImageBuffer::copyImage may return nullptr
+ in normal use and should be checked.
+
+ * platform/graphics/BitmapImage.cpp:
+ (WebCore::BitmapImage::drawPattern): Add nullptr check for create and copyImage. Remove
+ extra call to 'setImageObserver'.
+ * platform/graphics/cairo/ImageBufferCairo.cpp:
+ (WebCore::ImageBuffer::drawPattern): Add nullptr check for copyImage.
+ * platform/graphics/cg/ImageBufferCG.cpp:
+ (WebCore::ImageBuffer::drawPattern): Add nullptr checks for copyImage.
+ * platform/graphics/filters/FETile.cpp:
+ (WebCore::FETile::platformApplySoftware): Add nullptr check for copyImage.
+ * platform/graphics/filters/FilterEffect.cpp:
+ (WebCore::FilterEffect::asImageBuffer): Add nullptr check for create.
+ (WebCore::FilterEffect::openCLImageToImageBuffer): Ditto.
+ * platform/graphics/texmap/BitmapTexture.cpp:
+ (WebCore::BitmapTexture::updateContents): Add nullptr checks for create and copyImage.
+ * svg/graphics/SVGImage.cpp:
+ (WebCore::SVGImage::drawPatternForContainer): Add nullptr check for copyImage.
+
2015-06-19 Jeremy Jones <[email protected]>
Get CAContext directly for CALayer instead of walking the layer tree.
Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (185765 => 185766)
--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp 2015-06-19 20:40:11 UTC (rev 185765)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp 2015-06-19 20:45:54 UTC (rev 185766)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006 Samuel Weinig ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -617,13 +617,14 @@
}
if (!m_cachedImage) {
std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(tileRect.size()));
- ASSERT(buffer.get());
+ if (!buffer)
+ return;
ImageObserver* observer = imageObserver();
ASSERT(observer);
// Temporarily reset image observer, we don't want to receive any changeInRect() calls due to this relayout.
- setImageObserver(0);
+ setImageObserver(nullptr);
draw(buffer->context(), tileRect, tileRect, styleColorSpace, op, blendMode, ImageOrientationDescription());
@@ -631,9 +632,10 @@
buffer->convertToLuminanceMask();
m_cachedImage = buffer->copyImage(DontCopyBackingStore, Unscaled);
+ if (!m_cachedImage)
+ return;
+
m_cachedImage->setSpaceSize(spaceSize());
-
- setImageObserver(observer);
}
ctxt->setDrawLuminanceMask(false);
Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (185765 => 185766)
--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp 2015-06-19 20:40:11 UTC (rev 185765)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp 2015-06-19 20:45:54 UTC (rev 185766)
@@ -161,8 +161,8 @@
void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode)
{
- RefPtr<Image> image = copyImage(DontCopyBackingStore);
- image->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
+ if (RefPtr<Image> image = copyImage(DontCopyBackingStore))
+ image->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
}
void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (185765 => 185766)
--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp 2015-06-19 20:40:11 UTC (rev 185765)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp 2015-06-19 20:45:54 UTC (rev 185766)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <[email protected]>
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2015 Apple Inc. All rights reserved.
* Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -254,15 +254,15 @@
if (!context()->isAcceleratedContext()) {
if (destContext == context() || destContext->isAcceleratedContext()) {
- RefPtr<Image> copy = copyImage(CopyBackingStore); // Drawing into our own buffer, need to deep copy.
- copy->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect, blendMode);
+ if (RefPtr<Image> copy = copyImage(CopyBackingStore)) // Drawing into our own buffer, need to deep copy.
+ copy->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect, blendMode);
} else {
- RefPtr<Image> imageForRendering = copyImage(DontCopyBackingStore);
- imageForRendering->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect, blendMode);
+ if (RefPtr<Image> imageForRendering = copyImage(DontCopyBackingStore))
+ imageForRendering->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect, blendMode);
}
} else {
- RefPtr<Image> copy = copyImage(CopyBackingStore);
- copy->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect, blendMode);
+ if (RefPtr<Image> copy = copyImage(CopyBackingStore))
+ copy->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect, blendMode);
}
}
Modified: trunk/Source/WebCore/platform/graphics/filters/FETile.cpp (185765 => 185766)
--- trunk/Source/WebCore/platform/graphics/filters/FETile.cpp 2015-06-19 20:40:11 UTC (rev 185765)
+++ trunk/Source/WebCore/platform/graphics/filters/FETile.cpp 2015-06-19 20:45:54 UTC (rev 185766)
@@ -71,8 +71,12 @@
tileImageContext->translate(-inMaxEffectLocation.x(), -inMaxEffectLocation.y());
tileImageContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, in->absolutePaintRect().location());
- auto pattern = Pattern::create(tileImage->copyImage(CopyBackingStore), true, true);
+ auto tileImageCopy = tileImage->copyImage(CopyBackingStore);
+ if (!tileImageCopy)
+ return;
+ auto pattern = Pattern::create(tileImageCopy, true, true);
+
AffineTransform patternTransform;
patternTransform.translate(inMaxEffectLocation.x() - maxEffectLocation.x(), inMaxEffectLocation.y() - maxEffectLocation.y());
pattern.get().setPatternSpaceTransform(patternTransform);
Modified: trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp (185765 => 185766)
--- trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp 2015-06-19 20:40:11 UTC (rev 185765)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp 2015-06-19 20:45:54 UTC (rev 185766)
@@ -3,6 +3,7 @@
* Copyright (C) 2009 Dirk Schulze <[email protected]>
* Copyright (C) Research In Motion Limited 2010. All rights reserved.
* Copyright (C) 2012 University of Szeged
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -268,7 +269,7 @@
ImageBuffer* FilterEffect::asImageBuffer()
{
if (!hasResult())
- return 0;
+ return nullptr;
if (m_imageBufferResult)
return m_imageBufferResult.get();
#if ENABLE(OPENCL)
@@ -276,6 +277,9 @@
return openCLImageToImageBuffer();
#endif
m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size(), m_filter.filterScale(), m_resultColorSpace, m_filter.renderingMode());
+ if (!m_imageBufferResult)
+ return nullptr;
+
IntRect destinationRect(IntPoint(), m_absolutePaintRect.size());
if (m_premultipliedImageResult)
m_imageBufferResult->putByteArray(Premultiplied, m_premultipliedImageResult.get(), destinationRect.size(), destinationRect, IntPoint());
@@ -291,7 +295,7 @@
ASSERT(context);
if (context->inError())
- return 0;
+ return nullptr;
size_t origin[3] = { 0, 0, 0 };
size_t region[3] = { m_absolutePaintRect.width(), m_absolutePaintRect.height(), 1 };
@@ -299,12 +303,15 @@
RefPtr<Uint8ClampedArray> destinationPixelArray = Uint8ClampedArray::create(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);
if (context->isFailed(clFinish(context->commandQueue())))
- return 0;
+ return nullptr;
if (context->isFailed(clEnqueueReadImage(context->commandQueue(), m_openCLImageResult, CL_TRUE, origin, region, 0, 0, destinationPixelArray->data(), 0, 0, 0)))
- return 0;
+ return nullptr;
m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size());
+ if (!m_imageBufferResult)
+ return nullptr;
+
IntRect destinationRect(IntPoint(), m_absolutePaintRect.size());
m_imageBufferResult->putByteArray(Unmultiplied, destinationPixelArray.get(), destinationRect.size(), destinationRect, IntPoint());
Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp (185765 => 185766)
--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp 2015-06-19 20:40:11 UTC (rev 185765)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp 2015-06-19 20:45:54 UTC (rev 185766)
@@ -50,6 +50,8 @@
sourceLayer->paintGraphicsLayerContents(*context, sourceRect);
RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
+ if (!image)
+ return;
updateContents(image.get(), targetRect, IntPoint(), updateContentsFlag);
}
Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (185765 => 185766)
--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2015-06-19 20:40:11 UTC (rev 185765)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2015-06-19 20:45:54 UTC (rev 185766)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006 Eric Seidel <[email protected]>
- * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2015 Apple Inc. All rights reserved.
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -207,6 +207,8 @@
buffer->convertToLuminanceMask();
RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled);
+ if (!image)
+ return;
image->setSpaceSize(spaceSize());
// Adjust the source rect and transform due to the image buffer's scaling.
Modified: trunk/Source/WebKit/mac/ChangeLog (185765 => 185766)
--- trunk/Source/WebKit/mac/ChangeLog 2015-06-19 20:40:11 UTC (rev 185765)
+++ trunk/Source/WebKit/mac/ChangeLog 2015-06-19 20:45:54 UTC (rev 185766)
@@ -1,3 +1,19 @@
+2015-06-19 Brent Fulgham <[email protected]>
+
+ All calls of ImageBuffer::create should null check the return value
+ https://bugs.webkit.org/show_bug.cgi?id=22132
+
+ Reviewed by Zalan Bujtas.
+
+ ImageBuffer::create returns nullptr for a number of reasons, and should be
+ expected to do so. We missed this check in a few places, resulting in
+ crashes on some systems. Likewise, ImageBuffer::copyImage may return nullptr
+ in normal use and should be checked.
+
+ * WebCoreSupport/WebContextMenuClient.mm:
+ (WebContextMenuClient::imageForCurrentSharingServicePickerItem): Add nullptr check
+ for copyImage.
+
2015-06-18 Jon Lee <[email protected]>
Update AVKit usage of pip
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm (185765 => 185766)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm 2015-06-19 20:40:11 UTC (rev 185765)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm 2015-06-19 20:45:54 UTC (rev 185766)
@@ -483,6 +483,9 @@
frameView->setPaintBehavior(oldPaintBehavior);
RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore);
+ if (!image)
+ return nil;
+
return image->getNSImage();
}
#endif