[Python-checkins] bpo-36817: Fix reference leak for expr_text in f-string = parsing (GH-13249)

Pablo Galindo webhook-mailer at python.org
Sat May 11 15:54:40 EDT 2019


https://github.com/python/cpython/commit/5833e94d8615ea18b14e4830ecdb868aec81b378
commit: 5833e94d8615ea18b14e4830ecdb868aec81b378
branch: master
author: Pablo Galindo <Pablogsal at gmail.com>
committer: GitHub <noreply at github.com>
date: 2019-05-11T20:54:37+01:00
summary:

bpo-36817: Fix reference leak for expr_text in f-string = parsing (GH-13249)

files:
M Python/ast.c

diff --git a/Python/ast.c b/Python/ast.c
index 21abd7e88d84..585f8b3fba4c 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. */



More information about the Python-checkins mailing list