Skip to content

Commit

Permalink
yang parser BUGFIX allocate more patterns than currently needed
Browse files Browse the repository at this point in the history
Fixes #740
  • Loading branch information
michalvasko committed Mar 29, 2019
1 parent 19a0d67 commit a1f1769
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/parser_yang_bis.c
Original file line number Diff line number Diff line change
Expand Up @@ -4623,6 +4623,9 @@ YYLTYPE yylloc = yyloc_default;
!(data_node && data_node->nodetype != LYS_GROUPING && lys_ingrouping(data_node))) {
unsigned int c = 2 * (((struct yang_type *)(yyvsp[-2].backup_token).actual)->type->info.str.pat_count - 1);
YANG_ADDELEM(((struct yang_type *)(yyvsp[-2].backup_token).actual)->type->info.str.patterns_pcre, c, "patterns");
++c;
YANG_ADDELEM(((struct yang_type *)(yyvsp[-2].backup_token).actual)->type->info.str.patterns_pcre, c, "patterns");
actual = &(((struct yang_type *)(yyvsp[-2].backup_token).actual)->type->info.str.patterns_pcre)[2 * (((struct yang_type *)(yyvsp[-2].backup_token).actual)->type->info.str.pat_count - 1)];
}
#endif
if (yang_read_pattern(trg->ctx, pattern, actual, (yyvsp[-1].str), (yyvsp[0].ch))) {
Expand Down
3 changes: 3 additions & 0 deletions src/yang.y.in
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,9 @@ pattern_stmt: PATTERN_KEYWORD pattern_sep pattern_arg_str pattern_end {struct l
!(data_node && data_node->nodetype != LYS_GROUPING && lys_ingrouping(data_node))) {
unsigned int c = 2 * (((struct yang_type *)$2.actual)->type->info.str.pat_count - 1);
YANG_ADDELEM(((struct yang_type *)$2.actual)->type->info.str.patterns_pcre, c, "patterns");
++c;
YANG_ADDELEM(((struct yang_type *)$2.actual)->type->info.str.patterns_pcre, c, "patterns");
actual = &(((struct yang_type *)$2.actual)->type->info.str.patterns_pcre)[2 * (((struct yang_type *)$2.actual)->type->info.str.pat_count - 1)];
}
#endif
if (yang_read_pattern(trg->ctx, pattern, actual, $3, $4)) {
Expand Down

0 comments on commit a1f1769

Please sign in to comment.