Skip to content

Commit 1999a58

Browse files
committed
PR review improvements
1 parent 4f469d6 commit 1999a58

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎src/AngleSharp.Css/Values/Functions/CssVarValue.cs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ public String CssText
7979
{
8080
get
8181
{
82-
var text = new StringBuilder();
82+
var text = StringBuilderPool.Obtain();
8383
var value = this;
8484
var depth = 0;
8585

86-
while (true)
86+
// use a max-depth of 16384 to avoid stack overflows in case of circular references
87+
while (depth < 16384)
8788
{
8889
text.Append(FunctionNames.Var).Append('(').Append(value._variableName);
8990
depth++;
@@ -101,8 +102,10 @@ public String CssText
101102
text.Append(value._defaultValue.CssText);
102103
}
103104

104-
return text.Append(')', depth).ToString();
105+
break;
105106
}
107+
108+
return text.Append(')', depth).ToPool();
106109
}
107110
}
108111

0 commit comments

Comments
 (0)