bpo-40883: Fix memory leak in fstring_compile_expr in parse_string.c (GH-20667)

This commit is contained in:
Pablo Galindo 2020-06-06 00:52:15 +01:00 committed by GitHub
parent b084d1b97e
commit a54096e305
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View file

@ -0,0 +1 @@
Fix memory leak in when parsing f-strings in the new parser. Patch by Pablo Galindo

View 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;