]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40883: Fix memory leak in fstring_compile_expr in parse_string.c (GH-20667)
authorPablo Galindo <Pablogsal@gmail.com>
Fri, 5 Jun 2020 23:52:15 +0000 (00:52 +0100)
committerGitHub <noreply@github.com>
Fri, 5 Jun 2020 23:52:15 +0000 (00:52 +0100)
Misc/NEWS.d/next/Core and Builtins/2020-06-05-23-25-00.bpo-40883.M6sQ-Q.rst [new file with mode: 0644]
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 (file)
index 0000000..ebeb0cc
--- /dev/null
@@ -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
index e24ecc58d3aa1dc3acf7f05423ad3dd1720604ff..efe82df47658bdb4ad1b8d1c5d476b6cf3fd65f8 100644 (file)
@@ -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;