mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Clamp the repeat numbers greater than 10000
This was causing a crash in gecko mochitest because of OOM.
This commit is contained in:
parent
1ab86a46b6
commit
3f10488da1
2 changed files with 6 additions and 2 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue