Skip to content

Commit

Permalink
Merge pull request #2961 from guy-maurel/2960_too_many
Browse files Browse the repository at this point in the history
Change the value, make a check.
  • Loading branch information
gmaurel committed Oct 16, 2020
2 parents 8e2829b + e777854 commit 5eedea1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/align_func_proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ void align_func_proto(size_t span)
log_rule_B("align_var_def_amp_style");
size_t myamp_style = options::align_var_def_amp_style();

const size_t max_level_count = 4;
const size_t max_brace_level = 4;
const size_t max_level_count = 8;
const size_t max_brace_level = 8;

AlignStack many_as[max_level_count + 1][max_brace_level + 1];

Expand Down Expand Up @@ -81,6 +81,22 @@ void align_func_proto(size_t span)
__func__, __LINE__, pc->orig_line, pc->orig_col, pc->text(),
get_token_name(pc->type), pc->level, pc->brace_level);

if (pc->level > max_level_count) // Issue #2960
{
fprintf(stderr, "%s(%d): pc->level is %zu. This is too big, at line %zu, column %zu. Make a report, please.\n",
__func__, __LINE__, pc->level, pc->orig_line, pc->orig_col);
log_flush(true);
exit(EX_SOFTWARE);
}

if (pc->brace_level > max_brace_level)
{
fprintf(stderr, "%s(%d): pc->brace_level is %zu. This is too big, at line %zu, column %zu. Make a report, please.\n",
__func__, __LINE__, pc->level, pc->orig_line, pc->orig_col);
log_flush(true);
exit(EX_SOFTWARE);
}

if ( chunk_is_newline(pc)
&& !pc->flags.test(PCF_IN_FCN_CALL)) // Issue #2831
{
Expand Down

0 comments on commit 5eedea1

Please sign in to comment.