10000 bpo-40883: Fix memory leak in fstring_compile_expr in parse_string.c … · python/cpython@a54096e · GitHub
[go: up one dir, main page]

Skip to content

Commit a54096e

Browse files
authored
bpo-40883: Fix memory leak in fstring_compile_expr in parse_string.c (GH-20667)
1 parent b084d1b commit a54096e

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix memory leak in when parsing f-strings in the new parser. Patch by Pablo Galindo

Parser/pegen/parse_string.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
604604

605605
struct tok_state* tok = PyTokenizer_FromString(str, 1);
606606
if (tok == NULL) {
607+
PyMem_RawFree(str);
607608
return NULL;
608609
}
609610
Py_INCREF(p->tok->filename);
@@ -629,6 +630,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
629630
result = expr;
630631

631632
exit:
633+
PyMem_RawFree(str);
632634
_PyPegen_Parser_Free(p2);
633635
PyTokenizer_Free(tok);
634636
return result;

0 commit comments

Comments
 (0)
0