<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[174465] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/174465">174465</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2014-10-08 11:32:12 -0700 (Wed, 08 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Win] Resolve various static analyzer warnings in WebCore.
https://bugs.webkit.org/show_bug.cgi?id=137526

Reviewed by Dean Jackson.

A series of small changes to resolve various issues found by the MSVC static analyzer.

* inspector/NetworkResourcesData.cpp:
(WebCore::NetworkResourcesData::clear): Add assertion that it-&gt;value should never be null.
* page/SessionIDHash.h:
(WTF::HashTraits&lt;WebCore::SessionID&gt;::constructDeletedValue): Add explicit cast to avoid
compiler warning.
(WTF::HashTraits&lt;WebCore::SessionID&gt;::isDeletedValue): Ditto.
* page/win/FrameCGWin.cpp:
(WebCore::imageFromRect): Resolve static analyzer warnings by initializing bits, and
checking the return value of ::CreateDIBSection, which return nullptr on error.
* platform/graphics/ca/win/PlatformCALayerWin.cpp:
(printLayer): Use correct MSVC format specifier for size_t.
* platform/graphics/win/FontCacheWin.cpp:
(WebCore::getLinkedFonts): Handle possibility that a font link key does not exist.
(WebCore::FontCache::systemFallbackForCharacters): Handle error case when a valid code page
does not exist for a given character.
* platform/graphics/win/SimpleFontDataWin.cpp:
(WebCore::SimpleFontData::containsCharacters): Handle error cases for mapping to the CP_ACP code page,
and related failures when attempting to access the contents of a given code page.
* platform/graphics/win/UniscribeController.cpp:
(WebCore::UniscribeController::itemizeShapeAndPlace): Handle possible failure in the
ScriptItemize API call.
(WebCore::UniscribeController::shapeAndPlaceItem): Ditto for ScriptXtoCP API call.
* platform/win/BString.h: Use consistent SAL annotations for our typedeof of BSTR as in
the system header.
* platform/win/COMPtr.h: Ditto for HRESULT.
* platform/win/DragImageCGWin.cpp:
(WebCore::allocImage): Handle case of failing CreateDIBSection API call.
* platform/win/PopupMenuWin.cpp:
(WebCore::PopupMenuWin::show): Handle case of failing SystemParamtersInfo API call.
(WebCore::PopupMenuWin::wndProc): Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreinspectorNetworkResourcesDatacpp">trunk/Source/WebCore/inspector/NetworkResourcesData.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSessionIDHashh">trunk/Source/WebCore/page/SessionIDHash.h</a></li>
<li><a href="#trunkSourceWebCorepagewinFrameCGWincpp">trunk/Source/WebCore/page/win/FrameCGWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscawinPlatformCALayerWincpp">trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontCacheWincpp">trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinSimpleFontDataWincpp">trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinUniscribeControllercpp">trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformwinBStringh">trunk/Source/WebCore/platform/win/BString.h</a></li>
<li><a href="#trunkSourceWebCoreplatformwinCOMPtrh">trunk/Source/WebCore/platform/win/COMPtr.h</a></li>
<li><a href="#trunkSourceWebCoreplatformwinDragImageCGWincpp">trunk/Source/WebCore/platform/win/DragImageCGWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformwinPopupMenuWincpp">trunk/Source/WebCore/platform/win/PopupMenuWin.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/ChangeLog        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2014-10-08  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [Win] Resolve various static analyzer warnings in WebCore.
+        https://bugs.webkit.org/show_bug.cgi?id=137526
+
+        Reviewed by Dean Jackson.
+
+        A series of small changes to resolve various issues found by the MSVC static analyzer.
+
+        * inspector/NetworkResourcesData.cpp:
+        (WebCore::NetworkResourcesData::clear): Add assertion that it-&gt;value should never be null.
+        * page/SessionIDHash.h:
+        (WTF::HashTraits&lt;WebCore::SessionID&gt;::constructDeletedValue): Add explicit cast to avoid
+        compiler warning.
+        (WTF::HashTraits&lt;WebCore::SessionID&gt;::isDeletedValue): Ditto.
+        * page/win/FrameCGWin.cpp:
+        (WebCore::imageFromRect): Resolve static analyzer warnings by initializing bits, and
+        checking the return value of ::CreateDIBSection, which return nullptr on error.
+        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
+        (printLayer): Use correct MSVC format specifier for size_t.
+        * platform/graphics/win/FontCacheWin.cpp:
+        (WebCore::getLinkedFonts): Handle possibility that a font link key does not exist.
+        (WebCore::FontCache::systemFallbackForCharacters): Handle error case when a valid code page
+        does not exist for a given character.
+        * platform/graphics/win/SimpleFontDataWin.cpp:
+        (WebCore::SimpleFontData::containsCharacters): Handle error cases for mapping to the CP_ACP code page,
+        and related failures when attempting to access the contents of a given code page.
+        * platform/graphics/win/UniscribeController.cpp:
+        (WebCore::UniscribeController::itemizeShapeAndPlace): Handle possible failure in the
+        ScriptItemize API call.
+        (WebCore::UniscribeController::shapeAndPlaceItem): Ditto for ScriptXtoCP API call.
+        * platform/win/BString.h: Use consistent SAL annotations for our typedeof of BSTR as in
+        the system header.
+        * platform/win/COMPtr.h: Ditto for HRESULT.
+        * platform/win/DragImageCGWin.cpp:
+        (WebCore::allocImage): Handle case of failing CreateDIBSection API call.
+        * platform/win/PopupMenuWin.cpp:
+        (WebCore::PopupMenuWin::show): Handle case of failing SystemParamtersInfo API call.
+        (WebCore::PopupMenuWin::wndProc): Ditto.
+
</ins><span class="cx"> 2014-10-07  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [EME][Mac] Update CDMSessionMediaSourceAVFObjC to match new API provided by AVStreamSession
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorNetworkResourcesDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/NetworkResourcesData.cpp (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/NetworkResourcesData.cpp        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/inspector/NetworkResourcesData.cpp        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -338,6 +338,7 @@
</span><span class="cx">     ResourceDataMap::iterator end = m_requestIdToResourceDataMap.end();
</span><span class="cx">     for (it = m_requestIdToResourceDataMap.begin(); it != end; ++it) {
</span><span class="cx">         ResourceData* resourceData = it-&gt;value;
</span><ins>+        ASSERT(resourceData);
</ins><span class="cx">         if (!preservedLoaderId.isNull() &amp;&amp; resourceData-&gt;loaderId() == preservedLoaderId)
</span><span class="cx">             preservedMap.set(it-&gt;key, it-&gt;value);
</span><span class="cx">         else
</span></span></pre></div>
<a id="trunkSourceWebCorepageSessionIDHashh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/SessionIDHash.h (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/SessionIDHash.h        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/page/SessionIDHash.h        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -32,18 +32,19 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><del>-// The empty value is emptySessionID(), the deleted value is (-1)
</del><ins>+// The empty value is emptySessionID(), the deleted value is (-2)
</ins><span class="cx"> struct SessionIDHash {
</span><span class="cx">     static unsigned hash(const WebCore::SessionID&amp; p) { return (unsigned)p.sessionID(); }
</span><span class="cx">     static bool equal(const WebCore::SessionID&amp; a, const WebCore::SessionID&amp; b) { return a == b; }
</span><span class="cx">     static const bool safeToCompareToEmptyOrDeleted = true;
</span><span class="cx"> };
</span><span class="cx"> template&lt;&gt; struct HashTraits&lt;WebCore::SessionID&gt; : GenericHashTraits&lt;WebCore::SessionID&gt; {
</span><ins>+    static const uint64_t deletedValueIdentifier = 0xFFFFFFFFFFFFFFFE;
</ins><span class="cx">     static const bool needsDestruction = false;
</span><span class="cx">     static WebCore::SessionID emptyValue() { return WebCore::SessionID::emptySessionID(); }
</span><span class="cx"> 
</span><del>-    static void constructDeletedValue(WebCore::SessionID&amp; slot) { slot = WebCore::SessionID(-2); }
-    static bool isDeletedValue(const WebCore::SessionID&amp; slot) { return slot == WebCore::SessionID(-2); }
</del><ins>+    static void constructDeletedValue(WebCore::SessionID&amp; slot) { slot = WebCore::SessionID(deletedValueIdentifier); }
+    static bool isDeletedValue(const WebCore::SessionID&amp; slot) { return slot == WebCore::SessionID(deletedValueIdentifier); }
</ins><span class="cx"> };
</span><span class="cx"> template&lt;&gt; struct DefaultHash&lt;WebCore::SessionID&gt; {
</span><span class="cx">     typedef SessionIDHash Hash;
</span></span></pre></div>
<a id="trunkSourceWebCorepagewinFrameCGWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/win/FrameCGWin.cpp (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/win/FrameCGWin.cpp        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/page/win/FrameCGWin.cpp        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -55,13 +55,16 @@
</span><span class="cx">     PaintBehavior oldPaintBehavior = frame-&gt;view()-&gt;paintBehavior();
</span><span class="cx">     frame-&gt;view()-&gt;setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositingLayers);
</span><span class="cx"> 
</span><del>-    void* bits;
</del><ins>+    void* bits = nullptr;
</ins><span class="cx">     auto hdc = adoptGDIObject(::CreateCompatibleDC(0));
</span><span class="cx">     int w = ir.width();
</span><span class="cx">     int h = ir.height();
</span><span class="cx">     BitmapInfo bmp = BitmapInfo::create(IntSize(w, h));
</span><span class="cx"> 
</span><span class="cx">     GDIObject&lt;HBITMAP&gt; hbmp = adoptGDIObject(::CreateDIBSection(0, &amp;bmp, DIB_RGB_COLORS, static_cast&lt;void**&gt;(&amp;bits), 0, 0));
</span><ins>+    if (!hbmp)
+        return hbmp;
+
</ins><span class="cx">     HGDIOBJ hbmpOld = SelectObject(hdc.get(), hbmp.get());
</span><span class="cx">     CGContextRef context = CGBitmapContextCreate(static_cast&lt;void*&gt;(bits), w, h,
</span><span class="cx">         8, w * sizeof(RGBQUAD), deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscawinPlatformCALayerWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -669,7 +669,7 @@
</span><span class="cx">         if (CFGetTypeID(layerContents) == CGImageGetTypeID()) {
</span><span class="cx">             CGImageRef imageContents = static_cast&lt;CGImageRef&gt;(const_cast&lt;void*&gt;(layerContents));
</span><span class="cx">             printIndent(indent + 1);
</span><del>-            fprintf(stderr, &quot;(contents (image [%d %d]))\n&quot;,
</del><ins>+            fprintf(stderr, &quot;(contents (image [%Iu %Iu]))\n&quot;,
</ins><span class="cx">                 CGImageGetWidth(imageContents), CGImageGetHeight(imageContents));
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontCacheWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2007, 2008, 2013-2014 Apple Inc.  All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &lt;mlang.h&gt;
</span><span class="cx"> #include &lt;windows.h&gt;
</span><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><ins>+#include &lt;wtf/text/CString.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/StringHash.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringView.h&gt;
</span><span class="cx"> #include &lt;wtf/win/GDIObject.h&gt;
</span><span class="lines">@@ -97,12 +98,16 @@
</span><span class="cx"> 
</span><span class="cx">     result = new Vector&lt;String&gt;;
</span><span class="cx">     systemLinkMap.set(family, result);
</span><del>-    HKEY fontLinkKey;
</del><ins>+    HKEY fontLinkKey = nullptr;
</ins><span class="cx">     if (FAILED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, L&quot;Software\\Microsoft\\Windows NT\\CurrentVersion\\FontLink\\SystemLink&quot;, 0, KEY_READ, &amp;fontLinkKey)))
</span><span class="cx">         return result;
</span><span class="cx"> 
</span><span class="cx">     DWORD linkedFontsBufferSize = 0;
</span><del>-    RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination().data(), 0, NULL, NULL, &amp;linkedFontsBufferSize);
</del><ins>+    if (::RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination().data(), 0, nullptr, nullptr, &amp;linkedFontsBufferSize) == ERROR_FILE_NOT_FOUND) {
+        WTFLogAlways(&quot;The font link key %s does not exist in the registry.&quot;, family.utf8().data());
+        return result;
+    }
+
</ins><span class="cx">     WCHAR* linkedFonts = reinterpret_cast&lt;WCHAR*&gt;(malloc(linkedFontsBufferSize));
</span><span class="cx">     if (SUCCEEDED(RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination().data(), 0, NULL, reinterpret_cast&lt;BYTE*&gt;(linkedFonts), &amp;linkedFontsBufferSize))) {
</span><span class="cx">         unsigned i = 0;
</span><span class="lines">@@ -200,29 +205,29 @@
</span><span class="cx">     if (IMLangFontLinkType* langFontLink = getFontLinkInterface()) {
</span><span class="cx">         // Try MLang font linking first.
</span><span class="cx">         DWORD codePages = 0;
</span><del>-        langFontLink-&gt;GetCharCodePages(character, &amp;codePages);
-
-        if (codePages &amp;&amp; u_getIntPropertyValue(character, UCHAR_UNIFIED_IDEOGRAPH)) {
-            // The CJK character may belong to multiple code pages. We want to
-            // do font linking against a single one of them, preferring the default
-            // code page for the user's locale.
-            const Vector&lt;DWORD, 4&gt;&amp; CJKCodePageMasks = getCJKCodePageMasks();
-            unsigned numCodePages = CJKCodePageMasks.size();
-            for (unsigned i = 0; i &lt; numCodePages &amp;&amp; !hfont; ++i) {
-                hfont = createMLangFont(langFontLink, hdc, CJKCodePageMasks[i]);
-                if (hfont &amp;&amp; !(codePages &amp; CJKCodePageMasks[i])) {
-                    // We asked about a code page that is not one of the code pages
-                    // returned by MLang, so the font might not contain the character.
-                    SelectObject(hdc, hfont);
-                    if (!currentFontContainsCharacter(hdc, character)) {
-                        DeleteObject(hfont);
-                        hfont = 0;
</del><ins>+        if (SUCCEEDED(langFontLink-&gt;GetCharCodePages(character, &amp;codePages))) {
+            if (codePages &amp;&amp; u_getIntPropertyValue(character, UCHAR_UNIFIED_IDEOGRAPH)) {
+                // The CJK character may belong to multiple code pages. We want to
+                // do font linking against a single one of them, preferring the default
+                // code page for the user's locale.
+                const Vector&lt;DWORD, 4&gt;&amp; CJKCodePageMasks = getCJKCodePageMasks();
+                unsigned numCodePages = CJKCodePageMasks.size();
+                for (unsigned i = 0; i &lt; numCodePages &amp;&amp; !hfont; ++i) {
+                    hfont = createMLangFont(langFontLink, hdc, CJKCodePageMasks[i]);
+                    if (hfont &amp;&amp; !(codePages &amp; CJKCodePageMasks[i])) {
+                        // We asked about a code page that is not one of the code pages
+                        // returned by MLang, so the font might not contain the character.
+                        SelectObject(hdc, hfont);
+                        if (!currentFontContainsCharacter(hdc, character)) {
+                            DeleteObject(hfont);
+                            hfont = 0;
+                        }
+                        SelectObject(hdc, primaryFont);
</ins><span class="cx">                     }
</span><del>-                    SelectObject(hdc, primaryFont);
</del><span class="cx">                 }
</span><del>-            }
-        } else
-            hfont = createMLangFont(langFontLink, hdc, codePages, character);
</del><ins>+            } else
+                hfont = createMLangFont(langFontLink, hdc, codePages, character);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // A font returned from MLang is trusted to contain the character.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinSimpleFontDataWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -155,16 +155,23 @@
</span><span class="cx">     HWndDC dc(0);
</span><span class="cx"> 
</span><span class="cx">     DWORD acpCodePages;
</span><del>-    langFontLink-&gt;CodePageToCodePages(CP_ACP, &amp;acpCodePages);
</del><ins>+    if (FAILED(langFontLink-&gt;CodePageToCodePages(CP_ACP, &amp;acpCodePages))) {
+        WTFLogAlways(&quot;SimpleFontData::containsCharacters: Unable to convert to CP_ACP code page.&quot;);
+        return false;
+    }
</ins><span class="cx"> 
</span><span class="cx">     DWORD fontCodePages;
</span><del>-    langFontLink-&gt;GetFontCodePages(dc, m_platformData.hfont(), &amp;fontCodePages);
</del><ins>+    if (FAILED(langFontLink-&gt;GetFontCodePages(dc, m_platformData.hfont(), &amp;fontCodePages))) {
+        WTFLogAlways(&quot;SimpleFontData::containsCharacters: Unable to find matching code page for specified font.&quot;);
+        return false;
+    }
</ins><span class="cx"> 
</span><del>-    DWORD actualCodePages;
-    long numCharactersProcessed;
</del><ins>+    DWORD actualCodePages = 0;
+    long numCharactersProcessed = 0;
</ins><span class="cx">     long offset = 0;
</span><span class="cx">     while (offset &lt; length) {
</span><del>-        langFontLink-&gt;GetStrCodePages(characters, length, acpCodePages, &amp;actualCodePages, &amp;numCharactersProcessed);
</del><ins>+        if (FAILED(langFontLink-&gt;GetStrCodePages(characters, length, acpCodePages, &amp;actualCodePages, &amp;numCharactersProcessed)))
+            return false;
</ins><span class="cx">         if ((actualCodePages &amp; fontCodePages) == 0)
</span><span class="cx">             return false;
</span><span class="cx">         offset += numCharactersProcessed;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinUniscribeControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -196,10 +196,15 @@
</span><span class="cx">     // hanging out at the end of the array
</span><span class="cx">     m_items.resize(6);
</span><span class="cx">     int numItems = 0;
</span><del>-    while (ScriptItemize(cp, length, m_items.size() - 1, &amp;m_control, &amp;m_state, m_items.data(), &amp;numItems) == E_OUTOFMEMORY) {
</del><ins>+    HRESULT rc = S_OK;
+    while (rc = ::ScriptItemize(cp, length, m_items.size() - 1, &amp;m_control, &amp;m_state, m_items.data(), &amp;numItems) == E_OUTOFMEMORY) {
</ins><span class="cx">         m_items.resize(m_items.size() * 2);
</span><span class="cx">         resetControlAndState();
</span><span class="cx">     }
</span><ins>+    if (FAILED(rc)) {
+        WTFLogAlways(&quot;UniscribeController::itemizeShapeAndPlace: ScriptItemize failed, rc=%lx&quot;, rc);
+        return;
+    }
</ins><span class="cx">     m_items.resize(numItems + 1);
</span><span class="cx"> 
</span><span class="cx">     if (m_run.rtl()) {
</span><span class="lines">@@ -378,8 +383,12 @@
</span><span class="cx">     while (m_computingOffsetPosition &amp;&amp; m_offsetX &gt;= leftEdge &amp;&amp; m_offsetX &lt; m_runWidthSoFar) {
</span><span class="cx">         // The position is somewhere inside this run.
</span><span class="cx">         int trailing = 0;
</span><del>-        ScriptXtoCP(m_offsetX - leftEdge, clusters.size(), glyphs.size(), clusters.data(), visualAttributes.data(),
</del><ins>+        HRESULT rc = ::ScriptXtoCP(m_offsetX - leftEdge, clusters.size(), glyphs.size(), clusters.data(), visualAttributes.data(),
</ins><span class="cx">                     advances.data(), &amp;item.a, &amp;m_offsetPosition, &amp;trailing);
</span><ins>+        if (FAILED(rc)) {
+            WTFLogAlways(&quot;UniscribeController::shapeAndPlaceItem: ScriptXtoCP failed rc=%lx&quot;, rc);
+            return true;
+        }
</ins><span class="cx">         if (trailing &amp;&amp; m_includePartialGlyphs &amp;&amp; m_offsetPosition &lt; len - 1) {
</span><span class="cx">             m_offsetPosition += m_currentCharacter + m_items[i].iCharPos;
</span><span class="cx">             m_offsetX += m_run.rtl() ? -trailing : trailing;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformwinBStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/win/BString.h (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/win/BString.h        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/platform/win/BString.h        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -32,7 +32,11 @@
</span><span class="cx"> typedef const struct __CFString * CFStringRef;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#ifndef _PREFAST_
</ins><span class="cx"> typedef wchar_t* BSTR;
</span><ins>+#else // _PREFAST_
+typedef _Null_terminated_ wchar_t* BSTR;
+#endif
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformwinCOMPtrh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/win/COMPtr.h (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/win/COMPtr.h        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/platform/win/COMPtr.h        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -34,7 +34,11 @@
</span><span class="cx"> #include &lt;wtf/Assertions.h&gt;
</span><span class="cx"> #include &lt;wtf/HashTraits.h&gt;
</span><span class="cx"> 
</span><del>-typedef long HRESULT;
</del><ins>+#ifdef __midl
+typedef LONG HRESULT;
+#else
+typedef _Return_type_success_(return &gt;= 0) long HRESULT;
+#endif // __midl
</ins><span class="cx"> 
</span><span class="cx"> // FIXME: Should we put this into the WebCore namespace and use &quot;using&quot; on it
</span><span class="cx"> // as we do with things in WTF? 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformwinDragImageCGWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/win/DragImageCGWin.cpp (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/win/DragImageCGWin.cpp        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/platform/win/DragImageCGWin.cpp        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -49,10 +49,10 @@
</span><span class="cx"> {
</span><span class="cx">     BitmapInfo bmpInfo = BitmapInfo::create(size);
</span><span class="cx"> 
</span><del>-    LPVOID bits;
</del><ins>+    LPVOID bits = nullptr;
</ins><span class="cx">     auto hbmp = adoptGDIObject(::CreateDIBSection(dc, &amp;bmpInfo, DIB_RGB_COLORS, &amp;bits, 0, 0));
</span><span class="cx"> 
</span><del>-    if (!targetRef)
</del><ins>+    if (!targetRef || !hbmp)
</ins><span class="cx">         return hbmp;
</span><span class="cx"> 
</span><span class="cx">     CGContextRef bitmapContext = CGBitmapContextCreate(bits, bmpInfo.bmiHeader.biWidth, bmpInfo.bmiHeader.biHeight, 8,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformwinPopupMenuWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/win/PopupMenuWin.cpp (174464 => 174465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/win/PopupMenuWin.cpp        2014-10-08 18:31:14 UTC (rev 174464)
+++ trunk/Source/WebCore/platform/win/PopupMenuWin.cpp        2014-10-08 18:32:12 UTC (rev 174465)
</span><span class="lines">@@ -160,7 +160,8 @@
</span><span class="cx">             setFocusedIndex(index);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ::SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &amp;shouldAnimate, 0);
</del><ins>+    if (!::SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &amp;shouldAnimate, 0))
+        shouldAnimate = FALSE;
</ins><span class="cx"> 
</span><span class="cx">     if (shouldAnimate) {
</span><span class="cx">         RECT viewRect = {0};
</span><span class="lines">@@ -943,7 +944,8 @@
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             BOOL shouldHotTrack = FALSE;
</span><del>-            ::SystemParametersInfo(SPI_GETHOTTRACKING, 0, &amp;shouldHotTrack, 0);
</del><ins>+            if (!::SystemParametersInfo(SPI_GETHOTTRACKING, 0, &amp;shouldHotTrack, 0))
+                shouldHotTrack = FALSE;
</ins><span class="cx"> 
</span><span class="cx">             RECT bounds;
</span><span class="cx">             GetClientRect(popupHandle(), &amp;bounds);
</span></span></pre>
</div>
</div>

</body>
</html>