Skip to content

Commit

Permalink
Clamp the repeat numbers greater than 10000
Browse files Browse the repository at this point in the history
This was causing a crash in gecko mochitest because of OOM.
  • Loading branch information
canova committed Jul 19, 2017
1 parent 1ab86a4 commit 3f10488
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion components/style/properties/shorthand/position.mako.rs
Expand Up @@ -252,7 +252,6 @@
-> Result<(GridTemplateComponent,
GridTemplateComponent,
Either<TemplateAreas, None_>), ParseError<'i>> {

// Other shorthand sub properties also parse `none` and `subgrid` keywords and this
// shorthand should know after these keywords there is nothing to parse. Otherwise it
// gets confused and rejects the sub properties that contains `none` or `subgrid`.
Expand Down
7 changes: 6 additions & 1 deletion components/style/values/generics/grid.rs
Expand Up @@ -354,8 +354,13 @@ pub enum RepeatCount {

impl Parse for RepeatCount {
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
if let Ok(i) = input.try(|i| Integer::parse(context, i)) {
// Maximum number of repeat is 10000. The greater numbers should be clamped.
const MAX_LINE: i32 = 10000;
if let Ok(mut i) = input.try(|i| Integer::parse(context, i)) {
if i.value() > 0 {
if i.value() > MAX_LINE {
i = Integer::new(MAX_LINE);
}
Ok(RepeatCount::Number(i))
} else {
Err(StyleParseError::UnspecifiedError.into())
Expand Down

0 comments on commit 3f10488

Please sign in to comment.