Skip to content

Commit 9f364ee

Browse files
author
Chris Evans
committed
Crash accessing font fact rule parent
https://bugs.webkit.org/show_bug.cgi?id=71860 Reviewed by Adam Barth. Source/WebCore: Test: fast/css/css-fontface-rule-crash.html * css/CSSFontFaceRule.cpp: (WebCore::CSSFontFaceRule::~CSSFontFaceRule): tell our child rule when we are going away. LayoutTests: * fast/css/css-fontface-rule-crash-expected.txt: Added. * fast/css/css-fontface-rule-crash.html: Added. * resources/gc.js: Added. Add a re-usable best-of-breed gc(). Canonical link: https://commits.webkit.org/88216@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@99649 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 4d23447 commit 9f364ee

6 files changed

Lines changed: 83 additions & 0 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2011-11-08 Chris Evans <cevans@google.com>
2+
3+
Crash accessing font fact rule parent
4+
https://bugs.webkit.org/show_bug.cgi?id=71860
5+
6+
Reviewed by Adam Barth.
7+
8+
* fast/css/css-fontface-rule-crash-expected.txt: Added.
9+
* fast/css/css-fontface-rule-crash.html: Added.
10+
* resources/gc.js: Added. Add a re-usable best-of-breed gc().
11+
112
2011-11-08 Brent Fulgham <bfulgham@webkit.org>
213

314
[WinCairo] Unreviewed skiplist update to match main Windows
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PASS
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<html>
2+
<head>
3+
<script src="../../resources/gc.js"></script>
4+
<script>
5+
if (window.layoutTestController) {
6+
layoutTestController.dumpAsText();
7+
layoutTestController.waitUntilDone();
8+
}
9+
10+
function load()
11+
{
12+
style = document.createElement('style');
13+
style.textContent = '@font-face { font-family: "A"; }';
14+
document.head.appendChild(style);
15+
rulestyle = document.styleSheets[0].cssRules[0].style;
16+
document.head.removeChild(style);
17+
style = null;
18+
setTimeout(crash, 0);
19+
}
20+
21+
function crash()
22+
{
23+
gc();
24+
obj = rulestyle.parentRule;
25+
// If the gc() actually successfully reaps everything it can, then obj
26+
// will end up null (post-fix). gc() is not guaranteed to reap the font-face
27+
// rule, however, particularly in the browser context.
28+
if (obj)
29+
obj = obj.foo;
30+
document.body.innerText = 'PASS';
31+
if (window.layoutTestController)
32+
layoutTestController.notifyDone()
33+
}
34+
</script>
35+
</head>
36+
<body onload="load()"></body>
37+
</html>

LayoutTests/resources/gc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// If there is no window.gc() already defined, define one using the best
2+
// method we can find.
3+
// The slow fallback should not hit in the actual test environment.
4+
if (!window.gc)
5+
{
6+
window.gc = function()
7+
{
8+
if (window.GCController)
9+
return GCController.collect();
10+
function gcRec(n) {
11+
if (n < 1)
12+
return {};
13+
var temp = {i: "ab" + i + (i / 100000)};
14+
temp += "foo";
15+
gcRec(n-1);
16+
}
17+
for (var i = 0; i < 10000; i++)
18+
gcRec(10);
19+
}
20+
}

Source/WebCore/ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2011-11-08 Chris Evans <cevans@google.com>
2+
3+
Crash accessing font fact rule parent
4+
https://bugs.webkit.org/show_bug.cgi?id=71860
5+
6+
Reviewed by Adam Barth.
7+
8+
Test: fast/css/css-fontface-rule-crash.html
9+
10+
* css/CSSFontFaceRule.cpp:
11+
(WebCore::CSSFontFaceRule::~CSSFontFaceRule): tell our child rule when we are going away.
12+
113
2011-11-08 Adam Klein <adamk@chromium.org>
214

315
Use a typedef for ExceptionCode in all header files instead of including ExceptionCode.h

Source/WebCore/css/CSSFontFaceRule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ CSSFontFaceRule::CSSFontFaceRule(CSSStyleSheet* parent)
3333

3434
CSSFontFaceRule::~CSSFontFaceRule()
3535
{
36+
if (m_style)
37+
m_style->setParentRule(0);
3638
}
3739

3840
String CSSFontFaceRule::cssText() const

0 commit comments

Comments
 (0)