LibWeb/CSS: Fix crash resolving calc
with only percentages
#3007
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3006 , (relates to) #648
From some analysis, it seems as if this issue only occurs with a only percentages in a
calc
.calc(10%)
crashes.calc(10% + 10%)
crashes.calc(10% + 0px)
doesn't crash.calc(10vw)
doesn't crash.The
resolve
function returns aLength
in the general case, but returns aPercentage
if only percentages are provided.As a sanity check, I looked at the code before it was changed (commit before change was here), and it only handled the case of percentages and lengths, as I do in this commit.
The old code being:
Not sure if this is perfect, very open to constructive criticism.