8000 bpo-23689: re module, fix memory leak when a match is terminated by a signal or memory allocation failure · Pull Request #32283 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-23689: re module, fix memory leak when a match is terminated by a signal or memory allocation failure #32283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from Apr 3, 2022
Next Next commit
1. add variables
  • Loading branch information
wjssz committed Apr 3, 2022
commit e5317fe2fd80a8fbafd8420d1a9013276b89678f
2 changes: 1 addition & 1 deletion Lib/re/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# update when constants are added or removed

MAGIC = 20220318
MAGIC = 20220402

from _sre import MAXREPEAT, MAXGROUPS

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:mod:`re` module: fix memory leak when a match is terminated by a signal or
memory allocation failure. Patch by Ma Lin.
4 changes: 4 additions & 0 deletions Modules/sre.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ typedef struct {
Py_ssize_t groups; /* must be first! */
PyObject* groupindex; /* dict */
PyObject* indexgroup; /* tuple */
/* the number of REPEATs */
Py_ssize_t repeat_count;
/* compatibility */
PyObject* pattern; /* pattern source (or None) */
int flags; /* flags used when compiling pattern source */
Expand Down Expand Up @@ -83,6 +85,8 @@ typedef struct {
size_t data_stack_base;
/* current repeat context */
SRE_REPEAT *repeat;
/* repeat contexts array */
SRE_REPEAT *repeats_array;
} SRE_STATE;

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion Modules/sre_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* See the _sre.c file for information on usage and redistribution.
*/

#define SRE_MAGIC 20220318
#define SRE_MAGIC 20220402
#define SRE_OP_FAILURE 0
#define SRE_OP_SUCCESS 1
#define SRE_OP_ANY 2
Expand Down
0