From: Pieter Eendebak Date: Wed, 11 Mar 2026 13:24:15 +0000 (+0100) Subject: gh-145376: Fix refleak & pointer type bug in uncommon code paths in Parser/ (GH-145684) X-Git-Tag: v3.15.0a8~355 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f87c99a5ae9c74a5f94b91335d85f4662e1ed48;p=thirdparty%2FPython%2Fcpython.git gh-145376: Fix refleak & pointer type bug in uncommon code paths in Parser/ (GH-145684) --- diff --git a/Parser/pegen.c b/Parser/pegen.c index 7ecc55eee137..569f5afb3120 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -924,7 +924,6 @@ _PyPegen_set_syntax_error_metadata(Parser *p) { the_source // N gives ownership to metadata ); if (!metadata) { - Py_DECREF(the_source); PyErr_Clear(); return; } @@ -1026,8 +1025,8 @@ _PyPegen_run_parser_from_file_pointer(FILE *fp, int start_rule, PyObject *filena if (tok->fp_interactive && tok->interactive_src_start && result && interactive_src != NULL) { *interactive_src = PyUnicode_FromString(tok->interactive_src_start); - if (!interactive_src || _PyArena_AddPyObject(arena, *interactive_src) < 0) { - Py_XDECREF(interactive_src); + if (!*interactive_src || _PyArena_AddPyObject(arena, *interactive_src) < 0) { + Py_XDECREF(*interactive_src); result = NULL; goto error; }