From 312cdf18d56f4a7e19845c12afc3c678ce155f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Mon, 2 Jan 2023 15:18:02 +0100 Subject: [PATCH] Parser - Maximum argument count for functions --- src/parser.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/parser.rs b/src/parser.rs index 7212e5b..7d2a8e3 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -567,6 +567,12 @@ impl Parser { let mut arguments = Vec::new(); if !self.check(&TokenType::RightParen) { loop { + if arguments.len() == 255 { + return Err(ParserError::new( + self.peek(), + "functions may not have more than 255 arguments", + )); + } arguments.push(self.parse_expression()?); if self.expect(&[TokenType::Comma]).is_some() { break;