]> granicus.if.org Git - python/commitdiff
bpo-36817: Fix reference leak for expr_text in f-string = parsing (GH-13249)
authorPablo Galindo <Pablogsal@gmail.com>
Sat, 11 May 2019 19:54:37 +0000 (20:54 +0100)
committerGitHub <noreply@github.com>
Sat, 11 May 2019 19:54:37 +0000 (20:54 +0100)
Python/ast.c

index 21abd7e88d84585c3943f585b81880cd95c3bbcd..585f8b3fba4cdce67b424bee1f85ba85ddf306f7 100644 (file)
@@ -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. */