From ec9de132a8a18930b3668e02416bf23abdcb299f Mon Sep 17 00:00:00 2001 From: RuiliF Date: Sat, 14 Jan 2023 18:34:00 -0500 Subject: [PATCH 1/2] fix a potential memory leak in parser.c --- Parser/parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Parser/parser.c b/Parser/parser.c index d0bc25927bece6..ae41226ef68903 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -23803,7 +23803,8 @@ _loop0_1_rule(Parser *p) _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); if (!_new_children) { - p->error_indicator = 1; + PyMem_Free(_children); + p->error_indicator = 1; PyErr_NoMemory(); p->level--; return NULL; From f999f892e486246556d0ae25f1fa9c42f956a454 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 14 Jan 2023 23:51:58 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Security/2023-01-14-23-51-57.gh-issue-101046.rRu9EP.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Security/2023-01-14-23-51-57.gh-issue-101046.rRu9EP.rst diff --git a/Misc/NEWS.d/next/Security/2023-01-14-23-51-57.gh-issue-101046.rRu9EP.rst b/Misc/NEWS.d/next/Security/2023-01-14-23-51-57.gh-issue-101046.rRu9EP.rst new file mode 100644 index 00000000000000..48344f003ab4ca --- /dev/null +++ b/Misc/NEWS.d/next/Security/2023-01-14-23-51-57.gh-issue-101046.rRu9EP.rst @@ -0,0 +1,2 @@ +Fix a potential memory leak when :func:`PyMem_Realloc` fails inside +:func:`_loop0_1_rule`. Patch by Ruili Fang