<!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>[185095] trunk</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/185095">185095</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2015-06-01 19:10:05 -0700 (Mon, 01 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Out of bounds read in WebCore::ComplexTextController::adjustGlyphsAndAdvances
https://bugs.webkit.org/show_bug.cgi?id=145537
&lt;rdar://problem/20959267&gt;

Reviewed by Darin Adler.

Source/WebCore:

U16_IS_SURROGATE_LEAD(ch) assumes U16_IS_SURROGATE(ch). In this case, that isn't true.

Test: fast/text/crash-complex-text-surrogate.html

* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::adjustGlyphsAndAdvances):

LayoutTests:

* fast/text/crash-complex-text-surrogate.html: Added.
* platform/mac/fast/text/crash-complex-text-surrogate-expected.txt: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacComplexTextControllercpp">trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextcrashcomplextextsurrogatehtml">trunk/LayoutTests/fast/text/crash-complex-text-surrogate.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacfasttextcrashcomplextextsurrogateexpectedtxt">trunk/LayoutTests/platform/mac/fast/text/crash-complex-text-surrogate-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (185094 => 185095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-06-02 01:53:45 UTC (rev 185094)
+++ trunk/LayoutTests/ChangeLog        2015-06-02 02:10:05 UTC (rev 185095)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-06-01  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        Out of bounds read in WebCore::ComplexTextController::adjustGlyphsAndAdvances
+        https://bugs.webkit.org/show_bug.cgi?id=145537
+        &lt;rdar://problem/20959267&gt;
+
+        Reviewed by Darin Adler.
+
+        * fast/text/crash-complex-text-surrogate.html: Added.
+        * platform/mac/fast/text/crash-complex-text-surrogate-expected.txt: Added.
+
</ins><span class="cx"> 2015-05-30  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (179771): zooming on facebook images covers image
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextcrashcomplextextsurrogatehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/crash-complex-text-surrogate.html (0 => 185095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/crash-complex-text-surrogate.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/crash-complex-text-surrogate.html        2015-06-02 02:10:05 UTC (rev 185095)
</span><span class="lines">@@ -0,0 +1,88 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html id=&quot;webtest0&quot;&gt;
+&lt;head id=&quot;webtest1&quot;&gt;
+&lt;script id=&quot;webtest2&quot; type=&quot;text/javascript&quot;&gt;
+
+function boom()
+{
+  var y = document.createTextNode('Y');
+  document.body.insertBefore(y, document.getElementById(&quot;v&quot;).nextSibling);
+}
+
+&lt;/script&gt;
+&lt;/head&gt;
+
+&lt;body class=&quot;wf_class0&quot; id=&quot;webtest3&quot; onload=&quot;boom();&quot; style=&quot;-moz-column-count: 2; width: 10ch; letter-spacing: 1px; font-family: monospace;&quot;&gt;
+This test passes if you can open the file without a crash.
+&lt;div class=&quot;wf_class0&quot; style=&quot;background: lightblue; float: right; height: 14em; width: 1ch;&quot; id=&quot;v&quot;&gt;&lt;/div&gt;a bcd&lt;span id=&quot;webtest4&quot;&gt;&amp;#x202B;X&lt;/span&gt;
+&lt;/body&gt;
+&lt;script&gt;
+function webtest_fn_1() {
+try {
+delete document.scripts[3].toString();
+} catch(e) {
+  document.write(&quot;Errlog webtest_fn_1: &quot; + e.name + &quot;: &quot; + e.message + &quot;&lt;br&gt;&lt;acronym&gt;&lt;/acronym&gt;&quot;);
+}
+}
+webtest_fn_1();
+&lt;/script&gt;
+&lt;script&gt;
+function webtest_fn_2() {
+var s = &quot;{,}\ua888{0}\P{P}\\7H\\8&quot;;
+var f = &quot;gi&quot;;
+document.write(&quot;s is: &quot; +s + &quot;&lt;br&gt; f is: &quot; + f + &quot;&lt;br&gt;&quot;);
+var r = new RegExp(s, f);
+document.forms[0].outerHTML.search(r);
+r.compile(s, f);
+document.getElementById(&quot;webtest1&quot;).outerHTML.match(r);
+document.styleSheets[3].outerHTML.replace(r, &quot;replacement&quot;);
+r.test(s);
+r.exec(s);
+}
+webtest_fn_2();
+&lt;/script&gt;
+&lt;script&gt;
+function webtest_fn_3() {
+try {
+var head = document.getElementsByTagName(&quot;head&quot;)[0];
+var style = document.createElement(&quot;style&quot;);
+style.innerHTML=&quot;#wf_class0 { \n\
+-webkit-animation-name: name1; \n\
+-webkit-animation-duration: 1s; \n\
+-webkit-animation: none; \n\
+-webkit-animation-delay: now; \n\
+} \n\
+@-webkit-keyframes name1 { \n\
+  from { \n\
+    -webkit-mask-size: -4096%; \n\
+    background-image: -webkit-cross-fade(url(&amp;#x0056;&amp;#x00e8;&amp;#x0055;&amp;#x1e52;&amp;#x02e3;&amp;#x000f;&amp;#xbe6d;&amp;#x02c7;&amp;#x006c;&amp;#x22c4;&amp;#x00b9;&amp;#x02a1;&amp;#x01f3;&amp;#x00c1;&amp;#x01dc;&amp;#x0293;&amp;#x001f;&amp;#x0092;&amp;#x0298;&amp;#x07bb;&amp;#xbfae;&amp;#x0171;&amp;#x0034;&amp;#x024d;&amp;#x010c;&amp;#x016e;&amp;#x0132;&amp;#x01d6;&amp;#x02d9;&amp;#x00f1;&amp;#x01ff;&amp;#x02f5;&amp;#x02b1;&amp;#x39a6;&amp;#x022e;&amp;#x01c7;&amp;#x024f;&amp;#x0093;&amp;#x002e;&amp;#x00f5;&amp;#x0221;&amp;#xfac5;&amp;#x0164;&amp;#x2a35;&amp;#x00ad;&amp;#x02cd;&amp;#x02dc;&amp;#x00af;&amp;#x0161;&amp;#x0195;&amp;#x018e;), url(text), 99%); \n\
+  } \n\
+  to { \n\
+    -webkit-mask-size: 32767in; \n\
+    background-image: none; \n\
+  } \n\
+} \n\
+&quot;;
+head.appendChild(style);
+} catch(e) {
+  document.write(&quot;Errlog webtest_fn_3: &quot; + e.name + &quot;: &quot; + e.message + &quot;&lt;br&gt;&lt;sub/&gt;&quot;);
+}
+}
+webtest_fn_3();
+&lt;/script&gt;
+&lt;script&gt;
+function webtest_fn_4() {
+try {
+var scroll_81 = document.createElement(&quot;bdo&quot;);
+scroll_81.setAttribute(&quot;id&quot;, &quot;webtest8&quot;);
+document.querySelector(&quot;plaintext:first-of-type ~ *|:out-of-range&quot;).insertBefore(scroll_81, document.querySelector(&quot;plaintext:first-of-type ~ *|:out-of-range&quot;).childNodes[9]);
+scroll_81.setAttribute(&quot;style&quot;, &quot;overflow: scroll&quot;);
+scroll_81.scrollLeft = 0;
+scroll_81.scrolltop = 0xffffffff;
+} catch(e) {
+  document.write(&quot;Errlog webtest_fn_4: &quot; + e.name + &quot;: &quot; + e.message + &quot;&lt;br&gt;&quot;);
+}
+}
+webtest_fn_4();
+&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacfasttextcrashcomplextextsurrogateexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/fast/text/crash-complex-text-surrogate-expected.txt (0 => 185095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/text/crash-complex-text-surrogate-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/text/crash-complex-text-surrogate-expected.txt        2015-06-02 02:10:05 UTC (rev 185095)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+CONSOLE MESSAGE: line 35: TypeError: undefined is not an object (evaluating 'document.forms[0].outerHTML')
+layer at (0,0) size 785x693
+  RenderView at (0,0) size 785x600
+layer at (0,0) size 785x693
+  RenderBlock {HTML} at (0,0) size 785x693
+    RenderBody {BODY} at (8,8) size 78x677
+      RenderText {#text} at (0,0) size 71x120
+        text run at (0,0) width 36: &quot;This&quot;
+        text run at (0,15) width 36: &quot;test&quot;
+        text run at (0,30) width 53: &quot;passes&quot;
+        text run at (0,45) width 53: &quot;if you&quot;
+        text run at (0,60) width 71: &quot;can open&quot;
+        text run at (0,75) width 71: &quot;the file&quot;
+        text run at (0,90) width 62: &quot;without&quot;
+        text run at (0,105) width 71: &quot;a crash.&quot;
+      RenderBlock (floating) {DIV} at (70,120) size 8x182 [bgcolor=#ADD8E6]
+      RenderText {#text} at (0,120) size 9x15
+        text run at (0,120) width 9: &quot;Y&quot;
+      RenderText {#text} at (8,120) size 45x15
+        text run at (8,120) width 45: &quot;a bcd&quot;
+      RenderInline {SPAN} at (0,0) size 10x15
+        RenderText {#text} at (52,120) size 10x15
+          text run at (52,120) width 10: &quot;\x{202B}X&quot;
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,135) size 273x287
+        text run at (0,135) width 53: &quot;Errlog&quot;
+        text run at (0,302) width 115: &quot;webtest_fn_1:&quot;
+        text run at (0,317) width 89: &quot;TypeError:&quot;
+        text run at (0,332) width 80: &quot;undefined&quot;
+        text run at (0,347) width 53: &quot;is not&quot;
+        text run at (0,362) width 18: &quot;an&quot;
+        text run at (0,377) width 53: &quot;object&quot;
+        text run at (0,392) width 97: &quot;(evaluating&quot;
+        text run at (0,407) width 273: &quot;'document.scripts[3].toString')&quot;
+      RenderBR {BR} at (0,0) size 0x0
+      RenderInline {ACRONYM} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,422) size 115x45
+        text run at (0,422) width 45: &quot;s is:&quot;
+        text run at (0,437) width 27: &quot;{,}&quot;
+        text run at (0,452) width 115: &quot;\x{A888}{0}P{P}\\7H\\8&quot;
+      RenderBR {BR} at (0,0) size 0x0
+      RenderText {#text} at (0,467) size 71x15
+        text run at (0,467) width 71: &quot;f is: gi&quot;
+      RenderBR {BR} at (70,467) size 1x15
+      RenderText {#text} at (0,482) size 361x195
+        text run at (0,482) width 53: &quot;Errlog&quot;
+        text run at (0,497) width 115: &quot;webtest_fn_4:&quot;
+        text run at (0,512) width 89: &quot;TypeError:&quot;
+        text run at (0,527) width 62: &quot;null is&quot;
+        text run at (0,542) width 53: &quot;not an&quot;
+        text run at (0,557) width 53: &quot;object&quot;
+        text run at (0,572) width 97: &quot;(evaluating&quot;
+        text run at (0,587) width 361: &quot;'document.querySelector(\&quot;plaintext:first-&quot;
+        text run at (0,602) width 62: &quot;of-type&quot;
+        text run at (0,617) width 9: &quot;~&quot;
+        text run at (0,632) width 62: &quot;*|:out-&quot;
+        text run at (0,647) width 27: &quot;of-&quot;
+        text run at (0,662) width 194: &quot;range\&quot;).insertBefore')&quot;
+      RenderBR {BR} at (0,0) size 0x0
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (185094 => 185095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-06-02 01:53:45 UTC (rev 185094)
+++ trunk/Source/WebCore/ChangeLog        2015-06-02 02:10:05 UTC (rev 185095)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-06-01  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        Out of bounds read in WebCore::ComplexTextController::adjustGlyphsAndAdvances
+        https://bugs.webkit.org/show_bug.cgi?id=145537
+        &lt;rdar://problem/20959267&gt;
+
+        Reviewed by Darin Adler.
+
+        U16_IS_SURROGATE_LEAD(ch) assumes U16_IS_SURROGATE(ch). In this case, that isn't true.
+
+        Test: fast/text/crash-complex-text-surrogate.html
+
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
+
</ins><span class="cx"> 2015-05-30  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (179771): zooming on facebook images covers image
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacComplexTextControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp (185094 => 185095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp        2015-06-02 01:53:45 UTC (rev 185094)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp        2015-06-02 02:10:05 UTC (rev 185095)
</span><span class="lines">@@ -682,7 +682,7 @@
</span><span class="cx">                 if (advance.width)
</span><span class="cx">                     advance.width += m_font.letterSpacing();
</span><span class="cx"> 
</span><del>-                bool lastCharacter = static_cast&lt;unsigned&gt;(characterIndex + 1) == m_run.length() || (U16_IS_SURROGATE_LEAD(ch) &amp;&amp; static_cast&lt;unsigned&gt;(characterIndex + 2) == m_run.length() &amp;&amp; U16_IS_SURROGATE_TRAIL(*(cp + characterIndex + 1)));
</del><ins>+                bool lastCharacter = static_cast&lt;unsigned&gt;(characterIndex + 1) == complexTextRun.stringLength() || (U16_IS_LEAD(ch) &amp;&amp; static_cast&lt;unsigned&gt;(characterIndex + 2) == complexTextRun.stringLength() &amp;&amp; U16_IS_TRAIL(*(cp + characterIndex + 1)));
</ins><span class="cx"> 
</span><span class="cx">                 bool forceLeadingExpansion = false; // On the left, regardless of m_run.ltr()
</span><span class="cx">                 bool forceTrailingExpansion = false; // On the right, regardless of m_run.ltr()
</span></span></pre>
</div>
</div>

</body>
</html>