|
6 | 6 | and semantics are as close as possible to those of the Perl 5 language. |
7 | 7 |
|
8 | 8 | Written by Philip Hazel |
9 | | - Copyright (c) 1997-2020 University of Cambridge |
| 9 | + Copyright (c) 1997-2021 University of Cambridge |
10 | 10 |
|
11 | 11 | ----------------------------------------------------------------------------- |
12 | 12 | Redistribution and use in source and binary forms, with or without |
@@ -9104,6 +9104,8 @@ pcre_uchar cworkspace[COMPILE_WORK_SIZE]; |
9104 | 9104 | similar way to cworkspace, it can be expanded using malloc() if necessary. */ |
9105 | 9105 |
|
9106 | 9106 | named_group named_groups[NAMED_GROUP_LIST_SIZE]; |
| 9107 | +cd->named_groups = named_groups; |
| 9108 | +cd->named_group_list_size = NAMED_GROUP_LIST_SIZE; |
9107 | 9109 |
|
9108 | 9110 | /* Set this early so that early errors get offset 0. */ |
9109 | 9111 |
|
@@ -9377,8 +9379,6 @@ cd->hwm = cworkspace; |
9377 | 9379 | cd->iscondassert = FALSE; |
9378 | 9380 | cd->start_workspace = cworkspace; |
9379 | 9381 | cd->workspace_size = COMPILE_WORK_SIZE; |
9380 | | -cd->named_groups = named_groups; |
9381 | | -cd->named_group_list_size = NAMED_GROUP_LIST_SIZE; |
9382 | 9382 | cd->start_pattern = (const pcre_uchar *)pattern; |
9383 | 9383 | cd->end_pattern = (const pcre_uchar *)(pattern + STRLEN_UC((const pcre_uchar *)pattern)); |
9384 | 9384 | cd->req_varyopt = 0; |
@@ -9489,6 +9489,7 @@ if (cd->names_found > 0) |
9489 | 9489 | add_name(cd, ng->name, ng->length, ng->number); |
9490 | 9490 | if (cd->named_group_list_size > NAMED_GROUP_LIST_SIZE) |
9491 | 9491 | (PUBL(free))((void *)cd->named_groups); |
| 9492 | + cd->named_group_list_size = 0; /* So we don't free it twice */ |
9492 | 9493 | } |
9493 | 9494 |
|
9494 | 9495 | /* Set up a starting, non-extracting bracket, then compile the expression. On |
@@ -9639,6 +9640,8 @@ if (errorcode != 0) |
9639 | 9640 | { |
9640 | 9641 | (PUBL(free))(re); |
9641 | 9642 | PCRE_EARLY_ERROR_RETURN: |
| 9643 | + if (cd->named_group_list_size > NAMED_GROUP_LIST_SIZE) |
| 9644 | + (PUBL(free))((void *)cd->named_groups); |
9642 | 9645 | *erroroffset = (int)(ptr - (const pcre_uchar *)pattern); |
9643 | 9646 | PCRE_EARLY_ERROR_RETURN2: |
9644 | 9647 | *errorptr = find_error_text(errorcode); |
|
0 commit comments