Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a88b2f4

Browse files
committed
Fix reference leak in tb_printinternal()
Issue #26823.
1 parent 253021d commit a88b2f4

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Python/traceback.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ tb_printinternal(PyTracebackObject *tb, PyObject *f, long limit)
435435
line = PyUnicode_FromFormat(
436436
" [Previous line repeated %d more times]\n", cnt-3);
437437
err = PyFile_WriteObject(line, f, Py_PRINT_RAW);
438+
Py_DECREF(line);
438439
}
439440
last_file = tb->tb_frame->f_code->co_filename;
440441
last_line = tb->tb_lineno;
@@ -456,6 +457,7 @@ tb_printinternal(PyTracebackObject *tb, PyObject *f, long limit)
456457
line = PyUnicode_FromFormat(
457458
" [Previous line repeated %d more times]\n", cnt-3);
458459
err = PyFile_WriteObject(line, f, Py_PRINT_RAW);
460+
Py_DECREF(line);
459461
}
460462
return err;
461463
}

0 commit comments

Comments
 (0)