summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2019-05-11 19:54:37 (GMT)
committerGitHub <noreply@github.com>2019-05-11 19:54:37 (GMT)
commit5833e94d8615ea18b14e4830ecdb868aec81b378 (patch)
treedad68ea555f6e6d92e867ce51f94c31c69339325 /Python
parent90fb04c1e23c0fddd438bd0f73e7c018cacef4bc (diff)
downloadcpython-5833e94d8615ea18b14e4830ecdb868aec81b378.zip
cpython-5833e94d8615ea18b14e4830ecdb868aec81b378.tar.gz
cpython-5833e94d8615ea18b14e4830ecdb868aec81b378.tar.bz2
bpo-36817: Fix reference leak for expr_text in f-string = parsing (GH-13249)
Diffstat (limited to 'Python')
-rw-r--r--Python/ast.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 21abd7e..585f8b3 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -5228,10 +5228,15 @@ fstring_find_expr(const char **str, const char *end, int raw, int recurse_lvl,
}
if (equal_flag) {
- Py_ssize_t len = expr_text_end-expr_start;
+ Py_ssize_t len = expr_text_end - expr_start;
expr_text = PyUnicode_FromStringAndSize(expr_start, len);
- if (!expr_text)
+ if (!expr_text) {
goto error;
+ }
+ if (PyArena_AddPyObject(c->c_arena, expr_text) < 0) {
+ Py_DECREF(expr_text);
+ goto error;
+ }
}
/* Check for the format spec, if present. */