Skip to content

Commit

Permalink
bpo-36817: Fix reference leak for expr_text in f-string = parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
pablogsal committed May 11, 2019
1 parent 79972f1 commit 1094a6b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 1094a6b

Please sign in to comment.