Skip to content

Commit

Permalink
Added default length to createGridTrackBreadth() when length is undef…
Browse files Browse the repository at this point in the history
…ined

https://bugs.webkit.org/show_bug.cgi?id=269856
rdar://119619013

Reviewed by Sammy Gill.

`convertToLength` returned length undefined to `createGridTrackBreadth`
which causes an issue when creating GridLength. Added check to see if
length is undefined and if so returned a default length = 0 instead

* Source/WebCore/style/StyleBuilderConverter.h:
(WebCore::Style::BuilderConverter::createGridTrackBreadth):

Originally-landed-as: 272448.626@safari-7618-branch (0b6e286). rdar://128091169
Canonical link: https://commits.webkit.org/278871@main
  • Loading branch information
NKRosario authored and robert-jenner committed May 16, 2024
1 parent 332ec81 commit a5ef58e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

This test should not crash
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<iframe width="0" srcdoc='
<style>
* { grid-template-rows: 2vh 61px; -webkit-user-modify: read-write-plaintext-only; }
</style>
<script>
if (window.testRunner)
testRunner.dumpAsText();
function jsfuzzer() {
try { htmlvar00029.replaceWith("htmlvar00009"); var00145 = htmlvar00028.innerHTML; } catch(e) { }
try { /* */ var00144 = document.execCommand("insertHTML", false, var00145); } catch(e) { }
}
function eventhandler3() {
try { htmlvar00029.selectionDirection = String.fromCharCode(67, 93); } catch(e) { }
}
</script>
<body onload=jsfuzzer()>
<svg onload="eventhandler3()"></svg>
</svg>
<fieldset id="htmlvar00028">
<textarea id="htmlvar00029" value=".(e;">b26</textarea>
'></iframe>
<div>This test should not crash</div>
5 changes: 4 additions & 1 deletion Source/WebCore/style/StyleBuilderConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,10 @@ inline GridLength BuilderConverter::createGridTrackBreadth(const CSSPrimitiveVal
if (primitiveValue.isFlex())
return GridLength(primitiveValue.doubleValue());

return primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | AutoConversion>(builderState.cssToLengthConversionData());
auto length = primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | AutoConversion>(builderState.cssToLengthConversionData());
if (!length.isUndefined())
return length;
return Length(0.0, LengthType::Fixed);
}

inline GridTrackSize BuilderConverter::createGridTrackSize(const CSSValue& value, BuilderState& builderState)
Expand Down

0 comments on commit a5ef58e

Please sign in to comment.