diff --git a/src/config.h b/src/config.h index 299a0bd6d..644000d48 100644 --- a/src/config.h +++ b/src/config.h @@ -154,4 +154,9 @@ // #define CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN #endif /* CONFIG_ECMA_COMPACT_PROFILE */ +/** + * Maximum number of arguments in the engine's command line (i.e. maximum argc value) + */ +#define CONFIG_JERRY_MAX_COMMAND_LINE_ARGS 64 + #endif /* !CONFIG_H */ diff --git a/src/main.c b/src/main.c index 68c104169..0ea227bc5 100644 --- a/src/main.c +++ b/src/main.c @@ -138,7 +138,12 @@ int main (int argc __unused, char **argv __unused) { - const char *file_names[argc]; + if (argc > CONFIG_JERRY_MAX_COMMAND_LINE_ARGS) + { + jerry_exit (ERR_OUT_OF_MEMORY); + } + + const char *file_names[CONFIG_JERRY_MAX_COMMAND_LINE_ARGS]; bool parse_only = false, show_opcodes = false; bool print_mem_stats = false; int i;