[Python-checkins] bpo-40883: Fix memory leak in fstring_compile_expr in parse_string.c (GH-20667)
Pablo Galindo
webhook-mailer at python.org
Fri Jun 5 19:52:20 EDT 2020
https://github.com/python/cpython/commit/a54096e30523534e8eebb8dc1011b4536ed237a8
commit: a54096e30523534e8eebb8dc1011b4536ed237a8
branch: master
author: Pablo Galindo <Pablogsal at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020年06月06日T00:52:15+01:00
summary:
bpo-40883: Fix memory leak in fstring_compile_expr in parse_string.c (GH-20667)
files:
A Misc/NEWS.d/next/Core and Builtins/2020-06-05-23-25-00.bpo-40883.M6sQ-Q.rst
M Parser/pegen/parse_string.c
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-06-05-23-25-00.bpo-40883.M6sQ-Q.rst b/Misc/NEWS.d/next/Core and Builtins/2020-06-05-23-25-00.bpo-40883.M6sQ-Q.rst
new file mode 100644
index 0000000000000..ebeb0cc60d16b
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-06-05-23-25-00.bpo-40883.M6sQ-Q.rst
@@ -0,0 +1 @@
+Fix memory leak in when parsing f-strings in the new parser. Patch by Pablo Galindo
\ No newline at end of file
diff --git a/Parser/pegen/parse_string.c b/Parser/pegen/parse_string.c
index e24ecc58d3aa1..efe82df47658b 100644
--- a/Parser/pegen/parse_string.c
+++ b/Parser/pegen/parse_string.c
@@ -604,6 +604,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
struct tok_state* tok = PyTokenizer_FromString(str, 1);
if (tok == NULL) {
+ PyMem_RawFree(str);
return NULL;
}
Py_INCREF(p->tok->filename);
@@ -629,6 +630,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
result = expr;
exit:
+ PyMem_RawFree(str);
_PyPegen_Parser_Free(p2);
PyTokenizer_Free(tok);
return result;
More information about the Python-checkins
mailing list