Title: [136056] trunk
Revision
136056
Author
bfulg...@webkit.org
Date
2012-11-28 14:21:47 -0800 (Wed, 28 Nov 2012)

Log Message

[WinCairo] Crash when requesting favicon.
https://bugs.webkit.org/show_bug.cgi?id=102689

Patch by pe...@outlook.com <pe...@outlook.com> on 2012-11-28
Reviewed by Brent Fulgham.

Source/WebCore: 

* platform/graphics/BitmapImage.h: Made frameCount() method virtual, subclasses made for testing can then override it.
* platform/graphics/win/ImageCairoWin.cpp:
(WebCore::BitmapImage::getHBITMAPOfSize): Added NULL pointer check.
(WebCore::BitmapImage::drawFrameMatchingSourceSize): Added NULL pointer check.

Source/WebKit2: 

* win/WebKit2CFLite.def: Link fixes.
* win/WebKit2.def: Link fixes.

Tools: 

* TestWebKitAPI/Tests/WebCore/win: Added.
* TestWebKitAPI/Tests/WebCore/win/BitmapImage.cpp: Added.
(TestWebKitAPI::BitmapImageTest::BitmapImageTest): Allocate frame in constructor.
(TestWebKitAPI::BitmapImageTest::frameCount): Override frameCount() method.
(TestWebKitAPI::TEST): Added new test.
* TestWebKitAPI/config.h: Make sure defines are correct for WinCairo.
       * TestWebKitAPI/win/TestWebKitAPI.vcproj: Added new test.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (136055 => 136056)


--- trunk/Source/WebCore/ChangeLog	2012-11-28 22:14:03 UTC (rev 136055)
+++ trunk/Source/WebCore/ChangeLog	2012-11-28 22:21:47 UTC (rev 136056)
@@ -1,3 +1,15 @@
+2012-11-28  pe...@outlook.com  <pe...@outlook.com>
+
+        [WinCairo] Crash when requesting favicon.
+        https://bugs.webkit.org/show_bug.cgi?id=102689
+
+        Reviewed by Brent Fulgham.
+
+        * platform/graphics/BitmapImage.h: Made frameCount() method virtual, subclasses made for testing can then override it.
+        * platform/graphics/win/ImageCairoWin.cpp:
+        (WebCore::BitmapImage::getHBITMAPOfSize): Added NULL pointer check.
+        (WebCore::BitmapImage::drawFrameMatchingSourceSize): Added NULL pointer check.
+
 2012-11-28  Tony Chang  <t...@chromium.org>
 
         Move internals.settings.setPageScaleFactor to internals.setPageScaleFactor

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (136055 => 136056)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.h	2012-11-28 22:14:03 UTC (rev 136055)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h	2012-11-28 22:21:47 UTC (rev 136056)
@@ -218,7 +218,7 @@
 #endif
 
     size_t currentFrame() const { return m_currentFrame; }
-    size_t frameCount();
+    virtual size_t frameCount();
     NativeImagePtr frameAtIndex(size_t);
     bool frameIsCompleteAtIndex(size_t);
     float frameDurationAtIndex(size_t);

Modified: trunk/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp (136055 => 136056)


--- trunk/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp	2012-11-28 22:14:03 UTC (rev 136055)
+++ trunk/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp	2012-11-28 22:21:47 UTC (rev 136056)
@@ -62,7 +62,7 @@
     GetObject(bmp, sizeof(BITMAP), &bmpInfo);
 
     // If this is a 32bpp bitmap, which it always should be, we'll clear it so alpha-wise it will be visible
-    if (bmpInfo.bmBitsPixel == 32) {
+    if (bmpInfo.bmBitsPixel == 32 && bmpInfo.bmBits) {
         int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
         memset(bmpInfo.bmBits, 255, bufferSize);
     }
@@ -95,7 +95,10 @@
 {
     size_t frames = frameCount();
     for (size_t i = 0; i < frames; ++i) {
-        cairo_surface_t* image = frameAtIndex(i)->surface();
+        NativeImageCairo* nativeImage = frameAtIndex(i);
+        if (!nativeImage)
+            continue;
+        cairo_surface_t* image = nativeImage->surface();
         if (!image)
             continue;
 

Modified: trunk/Source/WebKit2/ChangeLog (136055 => 136056)


--- trunk/Source/WebKit2/ChangeLog	2012-11-28 22:14:03 UTC (rev 136055)
+++ trunk/Source/WebKit2/ChangeLog	2012-11-28 22:21:47 UTC (rev 136056)
@@ -1,3 +1,13 @@
+2012-11-28  pe...@outlook.com  <pe...@outlook.com>
+
+        [WinCairo] Crash when requesting favicon.
+        https://bugs.webkit.org/show_bug.cgi?id=102689
+
+        Reviewed by Brent Fulgham.
+
+        * win/WebKit2CFLite.def: Link fixes.
+        * win/WebKit2.def: Link fixes.
+
 2012-11-28  Christophe Dumez  <christophe.du...@intel.com>
 
         Regression(r135962): m_pendingSyncBackingStores needs to be cleared in LayerTreeRenderer::purgeGLResources()

Modified: trunk/Source/WebKit2/win/WebKit2.def (136055 => 136056)


--- trunk/Source/WebKit2/win/WebKit2.def	2012-11-28 22:14:03 UTC (rev 136055)
+++ trunk/Source/WebKit2/win/WebKit2.def	2012-11-28 22:21:47 UTC (rev 136056)
@@ -329,4 +329,34 @@
         ?layerTreeAsText@Frame@WebCore@@QBE?AVString@WTF@@I@Z
         ?trackedRepaintRectsAsText@Frame@WebCore@@QBE?AVString@WTF@@XZ
         ?setTracksRepaints@FrameView@WebCore@@QAEX_N@Z
-
+        ??1BitmapImage@WebCore@@UAE@XZ
+        ??0BitmapImage@WebCore@@IAE@PAVImageObserver@1@@Z
+        ?isBitmapImage@BitmapImage@WebCore@@UBE_NXZ
+        ?currentFrameHasAlpha@BitmapImage@WebCore@@UAE_NXZ
+        ?hasSingleSecurityOrigin@BitmapImage@WebCore@@UBE_NXZ
+        ?computeIntrinsicDimensions@Image@WebCore@@UAEXAAULength@2@0AAVFloatSize@2@@Z
+        ?size@BitmapImage@WebCore@@UBE?AVIntSize@2@XZ
+        ?getHotSpot@BitmapImage@WebCore@@UBE_NAAVIntPoint@2@@Z
+        ?dataChanged@BitmapImage@WebCore@@UAE_N_N@Z
+        ?filenameExtension@BitmapImage@WebCore@@UBE?AVString@WTF@@XZ
+        ?destroyDecodedData@BitmapImage@WebCore@@MAEX_N@Z
+        ?decodedSize@BitmapImage@WebCore@@UBEIXZ
+        ?startAnimation@BitmapImage@WebCore@@MAEX_N@Z
+        ?stopAnimation@BitmapImage@WebCore@@UAEXXZ
+        ?resetAnimation@BitmapImage@WebCore@@UAEXXZ
+        ?nativeImageForCurrentFrame@BitmapImage@WebCore@@UAEPAUCGImage@@XZ
+        ?getHBITMAP@BitmapImage@WebCore@@UAE_NPAUHBITMAP__@@@Z
+        ?getHBITMAPOfSize@BitmapImage@WebCore@@UAE_NPAUHBITMAP__@@PAUtagSIZE@@@Z
+        ?drawPattern@Image@WebCore@@UAEXPAVGraphicsContext@2@ABVFloatRect@2@ABVAffineTransform@2@ABVFloatPoint@2@W4ColorSpace@2@W4CompositeOperator@2@1@Z
+        ?reportMemoryUsage@BitmapImage@WebCore@@UBEXPAVMemoryObjectInfo@WTF@@@Z
+        ?drawFrameMatchingSourceSize@BitmapImage@WebCore@@MAEXPAVGraphicsContext@2@ABVFloatRect@2@ABVIntSize@2@W4ColorSpace@2@W4CompositeOperator@2@@Z
+        ?draw@Image@WebCore@@MAEXPAVGraphicsContext@2@ABVFloatRect@2@1W4ColorSpace@2@W4CompositeOperator@2@W4RespectImageOrientationEnum@2@@Z
+        ?draw@BitmapImage@WebCore@@MAEXPAVGraphicsContext@2@ABVFloatRect@2@1W4ColorSpace@2@W4CompositeOperator@2@@Z
+        ?mayFillWithSolidColor@BitmapImage@WebCore@@MAE_NXZ
+        ?solidColor@BitmapImage@WebCore@@MBE?AVColor@2@XZ
+        ?draw@BitmapImage@WebCore@@MAEXPAVGraphicsContext@2@ABVFloatRect@2@1W4ColorSpace@2@W4CompositeOperator@2@W4RespectImageOrientationEnum@2@@Z
+        ?frameCount@BitmapImage@WebCore@@MAEIXZ
+        ?getCGImageRef@BitmapImage@WebCore@@UAEPAUCGImage@@XZ
+        ?getFirstCGImageRefOfSize@BitmapImage@WebCore@@UAEPAUCGImage@@ABVIntSize@2@@Z
+        ?getCGImageArray@BitmapImage@WebCore@@UAE?AV?$RetainPtr@PBU__CFArray@@@WTF@@XZ
+        ?notSolidColor@BitmapImage@WebCore@@UAE_NXZ

Modified: trunk/Source/WebKit2/win/WebKit2CFLite.def (136055 => 136056)


--- trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-11-28 22:14:03 UTC (rev 136055)
+++ trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-11-28 22:21:47 UTC (rev 136056)
@@ -320,3 +320,32 @@
         ?layerTreeAsText@Frame@WebCore@@QBE?AVString@WTF@@I@Z
         ?trackedRepaintRectsAsText@Frame@WebCore@@QBE?AVString@WTF@@XZ
         ?setTracksRepaints@FrameView@WebCore@@QAEX_N@Z
+        ??1BitmapImage@WebCore@@UAE@XZ
+        ??0BitmapImage@WebCore@@IAE@PAVImageObserver@1@@Z
+        ?isBitmapImage@BitmapImage@WebCore@@UBE_NXZ
+        ?currentFrameHasAlpha@BitmapImage@WebCore@@UAE_NXZ
+        ?hasSingleSecurityOrigin@BitmapImage@WebCore@@UBE_NXZ
+        ?computeIntrinsicDimensions@Image@WebCore@@UAEXAAULength@2@0AAVFloatSize@2@@Z
+        ?size@BitmapImage@WebCore@@UBE?AVIntSize@2@XZ
+        ?getHotSpot@BitmapImage@WebCore@@UBE_NAAVIntPoint@2@@Z
+        ?dataChanged@BitmapImage@WebCore@@UAE_N_N@Z
+        ?filenameExtension@BitmapImage@WebCore@@UBE?AVString@WTF@@XZ
+        ?destroyDecodedData@BitmapImage@WebCore@@MAEX_N@Z
+        ?decodedSize@BitmapImage@WebCore@@UBEIXZ
+        ?startAnimation@BitmapImage@WebCore@@MAEX_N@Z
+        ?stopAnimation@BitmapImage@WebCore@@UAEXXZ
+        ?resetAnimation@BitmapImage@WebCore@@UAEXXZ
+        ?nativeImageForCurrentFrame@BitmapImage@WebCore@@UAEPAVNativeImageCairo@2@XZ
+        ?getHBITMAP@BitmapImage@WebCore@@UAE_NPAUHBITMAP__@@@Z
+        ?getHBITMAPOfSize@BitmapImage@WebCore@@UAE_NPAUHBITMAP__@@PAUtagSIZE@@@Z
+        ?drawPattern@Image@WebCore@@UAEXPAVGraphicsContext@2@ABVFloatRect@2@ABVAffineTransform@2@ABVFloatPoint@2@W4ColorSpace@2@W4CompositeOperator@2@1@Z
+        ?reportMemoryUsage@BitmapImage@WebCore@@UBEXPAVMemoryObjectInfo@WTF@@@Z
+        ?drawFrameMatchingSourceSize@BitmapImage@WebCore@@MAEXPAVGraphicsContext@2@ABVFloatRect@2@ABVIntSize@2@W4ColorSpace@2@W4CompositeOperator@2@@Z
+        ?draw@Image@WebCore@@MAEXPAVGraphicsContext@2@ABVFloatRect@2@1W4ColorSpace@2@W4CompositeOperator@2@W4RespectImageOrientationEnum@2@@Z
+        ?draw@BitmapImage@WebCore@@MAEXPAVGraphicsContext@2@ABVFloatRect@2@1W4ColorSpace@2@W4CompositeOperator@2@@Z
+        ?mayFillWithSolidColor@BitmapImage@WebCore@@MAE_NXZ
+        ?solidColor@BitmapImage@WebCore@@MBE?AVColor@2@XZ
+        ?frameAtIndex@BitmapImage@WebCore@@IAEPAVNativeImageCairo@2@I@Z
+        ?draw@BitmapImage@WebCore@@MAEXPAVGraphicsContext@2@ABVFloatRect@2@1W4ColorSpace@2@W4CompositeOperator@2@W4RespectImageOrientationEnum@2@@Z
+        ?frameCount@BitmapImage@WebCore@@MAEIXZ
+        ?notSolidColor@BitmapImage@WebCore@@UAE_NXZ

Modified: trunk/Tools/ChangeLog (136055 => 136056)


--- trunk/Tools/ChangeLog	2012-11-28 22:14:03 UTC (rev 136055)
+++ trunk/Tools/ChangeLog	2012-11-28 22:21:47 UTC (rev 136056)
@@ -1,3 +1,18 @@
+2012-11-28  pe...@outlook.com  <pe...@outlook.com>
+
+        [WinCairo] Crash when requesting favicon.
+        https://bugs.webkit.org/show_bug.cgi?id=102689
+
+        Reviewed by Brent Fulgham.
+
+        * TestWebKitAPI/Tests/WebCore/win: Added.
+        * TestWebKitAPI/Tests/WebCore/win/BitmapImage.cpp: Added.
+        (TestWebKitAPI::BitmapImageTest::BitmapImageTest): Allocate frame in constructor.
+        (TestWebKitAPI::BitmapImageTest::frameCount): Override frameCount() method.
+        (TestWebKitAPI::TEST): Added new test.
+        * TestWebKitAPI/config.h: Make sure defines are correct for WinCairo.
+       * TestWebKitAPI/win/TestWebKitAPI.vcproj: Added new test.
+
 2012-11-28  Eric Seidel  <e...@webkit.org>
 
         run-perf-tests should have a --profile option for easy profiling

Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/win/BitmapImage.cpp (0 => 136056)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/win/BitmapImage.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/win/BitmapImage.cpp	2012-11-28 22:21:47 UTC (rev 136056)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 pe...@outlook.com All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <WebCore/BitmapImage.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+// Test that there is no crash when BitmapImage::getHBITMAPOfSize() is called
+// for an image with empty frames (BitmapImage::frameAtIndex(i) return null), WebKit Bug 102689.
+
+class BitmapImageTest : public WebCore::BitmapImage {
+public:
+    BitmapImageTest()
+    {
+        m_frames.grow(1);
+    }
+
+    virtual size_t frameCount()
+    {
+        return 1;
+    }
+};
+
+TEST(WebCore, BitmapImageEmptyFrameTest)
+{
+    SIZE sz = {16, 16};
+    BitmapImageTest bitmapImageTest;
+    int bits[256];
+    HBITMAP hBitmap = CreateBitmap(16, 16, 1, 32, bits);
+    bitmapImageTest.getHBITMAPOfSize(hBitmap, &sz);
+}
+
+} // namespace TestWebKitAPI

Modified: trunk/Tools/TestWebKitAPI/config.h (136055 => 136056)


--- trunk/Tools/TestWebKitAPI/config.h	2012-11-28 22:14:03 UTC (rev 136055)
+++ trunk/Tools/TestWebKitAPI/config.h	2012-11-28 22:21:47 UTC (rev 136056)
@@ -47,8 +47,21 @@
 #define NOMINMAX
 #endif
 
+#if PLATFORM(WIN_CAIRO)
+#undef WTF_USE_CG
+#define WTF_USE_CAIRO 1
+#define WTF_USE_CURL 1
+#ifndef _WINSOCKAPI_
+#define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h
 #endif
+#elif !OS(WINCE)
+#define WTF_USE_CG 1
+#undef WTF_USE_CAIRO
+#undef WTF_USE_CURL
+#endif
 
+#endif
+
 #include <stdint.h>
 
 #if !PLATFORM(CHROMIUM) || (PLATFORM(GTK) && defined(BUILDING_WEBKIT2__))

Modified: trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj (136055 => 136056)


--- trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj	2012-11-28 22:14:03 UTC (rev 136055)
+++ trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj	2012-11-28 22:21:47 UTC (rev 136056)
@@ -421,6 +421,18 @@
 			Name="Tests"
 			>
 			<Filter
+				Name="WebCore"
+				>
+				<Filter
+					Name="win"
+					>
+					<File
+						RelativePath="..\Tests\WebCore\win\BitmapImage.cpp"
+						>
+					</File>
+				</Filter>
+			</Filter>
+			<Filter
 				Name="WebKit2"
 				>
 				<File
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to